Class: Reflex::Menu
- Inherits:
-
Object
- Object
- Reflex::Menu
- Includes:
- Enumerable, Xot::Hookable, Xot::Setter
- Defined in:
- lib/reflex/menu.rb
Instance Method Summary collapse
- #add_child(child, index: nil) ⇒ Object (also: #add)
- #check(bool = true) ⇒ Object
- #children ⇒ Object
- #disable ⇒ Object
- #each(&block) ⇒ Object
- #enable(bool = true) ⇒ Object
-
#initialize(label = nil, **options, &block) ⇒ Menu
constructor
A new instance of Menu.
- #inspect ⇒ Object
- #shortcut=(key_and_modifiers) ⇒ Object
- #uncheck ⇒ Object
Constructor Details
#initialize(label = nil, **options, &block) ⇒ Menu
Returns a new instance of Menu.
20 21 22 23 24 25 |
# File 'lib/reflex/menu.rb', line 20 def initialize(label = nil, **, &block) super() self.label = label if label set ** unless .empty? Xot::BlockUtil.instance_eval_or_block_call self, &block if block end |
Instance Method Details
#add_child(child, index: nil) ⇒ Object Also known as: add
27 28 29 |
# File 'lib/reflex/menu.rb', line 27 def add_child(child, index: nil) add_child! child, index end |
#check(bool = true) ⇒ Object
42 43 44 |
# File 'lib/reflex/menu.rb', line 42 def check(bool = true) check! bool end |
#children ⇒ Object
65 66 67 |
# File 'lib/reflex/menu.rb', line 65 def children() to_a end |
#disable ⇒ Object
38 39 40 |
# File 'lib/reflex/menu.rb', line 38 def disable() enable! false end |
#each(&block) ⇒ Object
60 61 62 63 |
# File 'lib/reflex/menu.rb', line 60 def each(&block) return enum_for :each unless block each!(&block) end |
#enable(bool = true) ⇒ Object
34 35 36 |
# File 'lib/reflex/menu.rb', line 34 def enable(bool = true) enable! bool end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/reflex/menu.rb', line 69 def inspect() "#<Reflex::Menu label:#{label.inspect} size:#{size}>" end |
#shortcut=(key_and_modifiers) ⇒ Object
50 51 52 53 54 |
# File 'lib/reflex/menu.rb', line 50 def shortcut=(key_and_modifiers) key, *mods = key_and_modifiers self.shortcut_key = key self.shortcut_modifiers = mods end |
#uncheck ⇒ Object
46 47 48 |
# File 'lib/reflex/menu.rb', line 46 def uncheck() check! false end |