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.
157 158 159 |
# File 'lib/everyday-menu/menu_item.rb', line 157 def commands @commands end |
Instance Method Details
#runBlock(sender) ⇒ Object
174 175 176 |
# File 'lib/everyday-menu/menu_item.rb', line 174 def runBlock(sender) @commands.execute(sender) unless @commands.nil? end |
#subscribe(parent, label, command_id = nil, &block) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/everyday-menu/menu_item.rb', line 159 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 |