-
-
Save lodestone/25704c2bab75718f81b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def applicationDidFinishLaunching(notification) | |
buildStatus(setupMenu) | |
end | |
def buildStatus(menu) | |
@statusBar = NSStatusBar.systemStatusBar | |
@item = @statusBar.statusItemWithLength(NSVariableStatusItemLength) | |
@item.retain | |
@item.setTitle("Menubar App") | |
@item.setHighlightMode(true) | |
@item.setMenu(menu) | |
end | |
def setupMenu | |
menu = NSMenu.new | |
menu.initWithTitle 'Menubar App' | |
mi = NSMenuItem.new | |
mi.title = 'Hello!' | |
mi.action = 'sayHello:' | |
menu.addItem mi | |
mi = NSMenuItem.new | |
mi.title = 'Quit' | |
mi.action = 'terminate:' | |
menu.addItem mi | |
menu | |
end | |
def sayHello(sender) | |
alert = NSAlert.new | |
alert.messageText = 'This is Rubymotion Status Bar Application' | |
alert.informativeText = 'Cool, huh?' | |
alert.alertStyle = NSInformationalAlertStyle | |
alert.addButtonWithTitle("Yeah!") | |
response = alert.runModal | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
$:.unshift("/Library/RubyMotion/lib") | |
require 'motion/project/template/osx' | |
Motion::Project::App.setup do |app| | |
# Use `rake config' to see complete project settings. | |
app.name = 'MenubarApp' | |
app.info_plist['NSUIElement'] = 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment