class MotionKit::NSMenuHelpers
Public Instance Methods
about_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 92 def about_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, "About #{app_name}", { action: 'orderFrontStandardAboutPanel:' }) return self.item(title, options) end
app_name()
click to toggle source
useful when writing menus
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 6 def app_name # this returns an ImmediateRef, whatever that is. It needs to be # converted to a String. Doesn't work in 10.10. "#{NSBundle.mainBundle.infoDictionary['CFBundleName']}" end
attributedTitle(value)
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 18 def attributedTitle(value) target.title = value.to_s @menu_item.attributedTitle = value end
attributed_title(value)
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 23 def attributed_title(value) target.title = value.to_s @menu_item.attributedTitle = value end
bring_all_to_front_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 177 def bring_all_to_front_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Bring All To Front', { action: 'arrangeInFront:' }) return self.item(title, options) end
close_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 137 def close_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Close', { key: 'w', action: 'performClose:' }) return self.item(title, options) end
help_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 182 def help_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, "#{app_name} Help", { key: '?', action: 'showHelp:' }) return self.item("#{app_name} Help", options) end
hide_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 107 def hide_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, "Hide #{app_name}", { key: 'h', action: 'hide:' }) return self.item(title, options) end
hide_others_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 112 def hide_others_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Hide Others', { key: 'h', action: 'hideOtherApplications:', mask: NSCommandKeyMask | NSAlternateKeyMask }) return self.item(title, options) end
keyEquivalentModifierMask(value)
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 36 def keyEquivalentModifierMask(value) @menu_item.keyEquivalentModifierMask = value end
key_equivalent_modifier_mask(value)
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 40 def key_equivalent_modifier_mask(value) @menu_item.keyEquivalentModifierMask = value end
minimize_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 167 def minimize_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Minimize', { key: 'm', action: 'performMiniaturize:' }) return self.item(title, options) end
new_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 127 def new_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'New', { key: 'n', action: 'newDocument:' }) return self.item(title, options) end
open_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 132 def open_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Open…', { key: 'o', action: 'openDocument:' }) return self.item(title, options) end
page_setup_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 157 def page_setup_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Page Setup…', { key: 'P', action: 'runPageLayout:' }) return self.item(title, options) end
preferences_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 97 def preferences_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Preferences', { key: ',', action: 'openPreferences:' }) return self.item(title, options) end
print_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 162 def print_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Print…', { key: 'p', action: 'printDocument:' }) return self.item(title, options) end
quit_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 122 def quit_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, "Quit #{app_name}", { key: 'q', action: 'terminate:' }) return self.item(title, options) end
revert_to_save_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 152 def revert_to_save_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Revert to Saved', { action: 'revertDocumentToSaved:' }) return self.item(title, options) end
save_as_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 147 def save_as_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Save as…', { key: 'S', action: 'saveDocumentAs:' }) return self.item(title, options) end
save_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 142 def save_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Save…', { key: 's', action: 'saveDocument:' }) return self.item(title, options) end
separator_item()
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 88 def separator_item NSMenuItem.separatorItem end
services_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 102 def services_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Services') return self.item(title, options) end
show_all_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 117 def show_all_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Show All', { action: 'unhideAllApplications:' }) return self.item(title, options) end
state(value)
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 28 def state(value) @menu_item.state = value end
tag(value)
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 32 def tag(value) @menu_item.tag = value end
title(value)
click to toggle source
sets the title of the current NSMenu AND it's parent NSMenuItem
# File lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb, line 13 def title(value) target.title = value @menu_item.title = value end
zoom_item(title=nil, options={})
click to toggle source
# File lib/motion-kit-osx/helpers/nsmenu_extensions.rb, line 172 def zoom_item(title=nil, options={}) title, options = _menu_title_and_options(title, options, 'Zoom', { action: 'performMiniaturize:' }) return self.item(title, options) end