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