Created
May 17, 2010 06:15
-
-
Save mattetti/403462 to your computer and use it in GitHub Desktop.
This file contains 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
framework 'AppKit' | |
app = NSApplication.sharedApplication | |
class ItemDelegate | |
def define_actions(actions) | |
actions.each do |command| | |
self.class.send(:define_method, command) do |sender| | |
puts command | |
end | |
end | |
end | |
def quit(sender) | |
exit | |
end | |
end | |
@menu = NSMenu.alloc.init | |
actions = ['test', 'test2'] | |
menu_delegate = ItemDelegate.new | |
menu_delegate.define_actions(actions) | |
actions.each do |action| | |
item = @menu.addItemWithTitle(action, action: action, keyEquivalent: "") | |
item.target = menu_delegate | |
end | |
item = @menu.addItemWithTitle("Quit", action: 'quit:', keyEquivalent: "q") | |
item.toolTip = "Click to close this App" | |
item.target = menu_delegate | |
bar = NSStatusBar.systemStatusBar.statusItemWithLength(NSSquareStatusItemLength) | |
bar.title = "test" | |
bar.menu = @menu | |
bar.highlightMode = true | |
app.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment