Sha256: 82822c7070f0fcf257633abd1b067117cc3cb9fee31d1ecc727cca8acc1a336c

Contents?: true

Size: 1.08 KB

Versions: 15

Compression:

Stored size: 1.08 KB

Contents

# @requires MotionKit::NSMenuHelpers
module MotionKit
  class NSMenuHelpers

    ##|
    ##|  These methods are meant to be called on the parent menu item, but
    ##|  there's no way to reference an NSMenu's parent *item* (only its parent
    ##|  *menu*).  So the @menu_item is stored in an ivar before the menu block
    ##|  is created, and these methods access that menu item.
    ##|

    # sets the title of the current NSMenu AND it's parent NSMenuItem
    def title(value)
      target.title = value
      @menu_item.title = value
    end

    def attributedTitle(value)
      target.title = value.to_s
      @menu_item.attributedTitle = value
    end

    def attributed_title(value)
      target.title = value.to_s
      @menu_item.attributedTitle = value
    end

    def state(value)
      @menu_item.state = value
    end

    def tag(value)
      @menu_item.tag = value
    end

    def keyEquivalentModifierMask(value)
      @menu_item.keyEquivalentModifierMask = value
    end

    def key_equivalent_modifier_mask(value)
      @menu_item.keyEquivalentModifierMask = value
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
motion-kit-1.1.1 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-1.1.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-1.0.3 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-1.0.2 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-1.0.1 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-1.0.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.18.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.17.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.16.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.15.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.14.2 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.14.1 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.14.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.13.0 lib/motion-kit-osx/helpers/nsmenuitem_extensions.rb
motion-kit-0.12.0 lib/motion-kit-osx/layouts/nsmenuitem_extensions.rb