Module: RubyCurses::WidgetMenu

Includes:
Io
Defined in:
lib/rbcurse/core/include/widgetmenu.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Io

#__create_footer_window, #clear_this, #get_file, #print_this, #rb_getchar, #rb_gets, #rbgetstr, #warn

Class Method Details

.extended(obj) ⇒ Object

add a menu item which can any one of

Parameters:

  • key,

    label, desc, action | symbol key, symbol Action Action[] (maybe)



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rbcurse/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.init_menu if obj.respond_to? :init_menu
  }

end

Instance Method Details

#_show_menuObject

popup the hist



55
56
57
58
59
60
61
62
63
64
# File 'lib/rbcurse/core/include/widgetmenu.rb', line 55

def _show_menu
  return if @_menuitems.nil? || @_menuitems.empty?
  list = @_menuitems
  menu = PromptMenu.new self do |m|
  list.each { |e| 
    m.add *e
  }
  end
  menu.display_new :title => 'Widget Menu (Press letter)'
end

#add_menu_item(*val) ⇒ Object



39
40
41
42
# File 'lib/rbcurse/core/include/widgetmenu.rb', line 39

def add_menu_item *val
  #@_menuitems ||= []
  @_menuitems << val
end

#create_menuitem(*args) ⇒ Object



49
50
51
# File 'lib/rbcurse/core/include/widgetmenu.rb', line 49

def create_menuitem *args
  PromptMenu.create_menuitem *args
end

#insert_menu_item(pos, *val) ⇒ Object

insert an item at given position (index)



45
46
47
48
# File 'lib/rbcurse/core/include/widgetmenu.rb', line 45

def insert_menu_item pos, *val
  #@_menuitems ||= []
  @_menuitems[pos] = val
end