Class: NSMenuItem
- Inherits:
-
Object
- Object
- NSMenuItem
- Defined in:
- lib/everyday-menu/menu_item.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Instance Method Summary collapse
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
134 135 136 |
# File 'lib/everyday-menu/menu_item.rb', line 134 def commands @commands end |
Instance Method Details
#runBlock(sender) ⇒ Object
152 153 154 |
# File 'lib/everyday-menu/menu_item.rb', line 152 def runBlock(sender) @commands.execute(sender) unless @commands.nil? end |
#subscribe(parent, label, command_id = nil, &block) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/everyday-menu/menu_item.rb', line 136 def subscribe(parent, label, command_id = nil, &block) @commands ||= EverydayMenu::CommandList.new(parent, label) @commands.add command_id, &block command = @commands.last self.enabled = @commands.canExecute unless @boundEnabled @boundEnabled = true self.bind(NSEnabledBinding, toObject: self.commands, withKeyPath: 'canExecute', options: nil) end return command if (self.target = self && self.action == :'runBlocks:') @original_target = self.target self.target = self self.action = :'runBlock:' command end |