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.
186 187 188 |
# File 'lib/everyday-menu/menu_item.rb', line 186 def commands @commands end |
Instance Method Details
#runBlock(sender) ⇒ Object
203 204 205 |
# File 'lib/everyday-menu/menu_item.rb', line 203 def runBlock(sender) @commands.execute(sender) unless @commands.nil? end |
#subscribe(parent, label, command_id = nil, &block) ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/everyday-menu/menu_item.rb', line 188 def subscribe(parent, label, command_id = nil, &block) @commands ||= parent.commands command = parent.commands.add command_id, &block self.enabled = parent.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 |