Module: Canis::WidgetMenu
- Includes:
- Io
- Defined in:
- lib/canis/core/include/widgetmenu.rb
Class Method Summary collapse
-
.extended(obj) ⇒ Object
add a menu item which can any one of.
Instance Method Summary collapse
-
#_show_menu ⇒ Object
popup the hist.
- #add_menu_item(*val) ⇒ Object
- #create_menuitem(*args) ⇒ Object
-
#insert_menu_item(pos, *val) ⇒ Object
insert an item at given position (index).
Methods included from Io
#__create_footer_window, #clear_this, #get_file, #print_this, #rb_getchar, #rb_gets, #rb_getstr, #warn
Class Method Details
.extended(obj) ⇒ Object
add a menu item which can any one of
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/canis/core/include/widgetmenu.rb', line 24 def self.extended(obj) # don't want this executed each time @objects ||= [] return if @objects.include? obj @objects << obj obj.instance_exec { @_menuitems ||= [] # callign this method means that no other programs can use those actions else # that method will be called more than once, so it must either be called in the constructor # or else have a check that it is only called once. obj. if obj.respond_to? :init_menu } end |
Instance Method Details
#_show_menu ⇒ Object
popup the hist
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/canis/core/include/widgetmenu.rb', line 55 def return if @_menuitems.nil? || @_menuitems.empty? list = @_menuitems = PromptMenu.new self do |m| list.each { |e| m.add *e } end .display_new :title => 'Widget Menu (Press letter)' end |
#add_menu_item(*val) ⇒ Object
39 40 41 42 |
# File 'lib/canis/core/include/widgetmenu.rb', line 39 def *val #@_menuitems ||= [] @_menuitems << val end |
#create_menuitem(*args) ⇒ Object
49 50 51 |
# File 'lib/canis/core/include/widgetmenu.rb', line 49 def *args PromptMenu. *args end |
#insert_menu_item(pos, *val) ⇒ Object
insert an item at given position (index)
45 46 47 48 |
# File 'lib/canis/core/include/widgetmenu.rb', line 45 def pos, *val #@_menuitems ||= [] @_menuitems[pos] = val end |