In Files

  • tk/lib/tk/menu.rb

Class/Module Index [+]

Quicksearch

OptionMenuButton

Constants

TkCommandNames

Public Class Methods

new(*args) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 594
def initialize(*args)
  # args :: [parent,] [var,] [value[, ...],] [keys]
  #    parent --> TkWindow or nil
  #    var    --> TkVariable or nil
  #    keys   --> Hash
  #       keys[:parent] or keys['parent']     --> parent
  #       keys[:variable] or keys['variable'] --> var
  #       keys[:values] or keys['values']     --> value, ...
  #       other Hash keys are menubutton options
  keys = {}
  keys = args.pop if args[-1].kind_of?(Hash)
  keys = _symbolkey2str(keys)

  parent = nil
  if !args.empty? && (args[0].kind_of?(TkWindow) || args[0] == nil)
    keys.delete('parent') # ignore
    parent = args.shift
  else
    parent = keys.delete('parent')
  end

  @variable = nil
  if !args.empty? && (args[0].kind_of?(TkVariable) || args[0] == nil)
    keys.delete('variable') # ignore
    @variable = args.shift
  else
    @variable = keys.delete('variable')
  end
  @variable = TkVariable.new unless @variable

  (args = keys.delete('values') || []) if args.empty?
  if args.empty?
    args << @variable.value
  else
    @variable.value = args[0]
  end

  install_win(if parent then parent.path end)
  @menu = OptionMenu.new(tk_call('tk_optionMenu',
                                 @path, @variable.id, *args))

  configure(keys) if keys
end
            

Public Instance Methods

activate(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 646
def activate(index)
  @menu.activate(index)
  self
end
            
add(value) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 650
def add(value)
  @menu.add('radiobutton', 'variable'=>@variable,
            'label'=>value, 'value'=>value)
  self
end
            
current_entryconfiginfo(index, key=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 708
def current_entryconfiginfo(index, key=nil)
  @menu.current_entryconfiginfo(index, key)
end
            
current_menuconfiginfo(key=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 692
def current_menuconfiginfo(key=nil)
  @menu.current_configinfo(key)
end
            
delete(index, last=None) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 666
def delete(index, last=None)
  @menu.delete(index, last)
  self
end
            
entrycget(index, key) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 695
def entrycget(index, key)
  @menu.entrycget(index, key)
end
            
entrycget_strict(index, key) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 698
def entrycget_strict(index, key)
  @menu.entrycget_strict(index, key)
end
            
entryconfiginfo(index, key=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 705
def entryconfiginfo(index, key=nil)
  @menu.entryconfiginfo(index, key)
end
            
entryconfigure(index, key, val=None) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 701
def entryconfigure(index, key, val=None)
  @menu.entryconfigure(index, key, val)
  self
end
            
index(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 655
def index(index)
  @menu.index(index)
end
            
insert(index, value) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 661
def insert(index, value)
  @menu.insert(index, 'radiobutton', 'variable'=>@variable,
            'label'=>value, 'value'=>value)
  self
end
            
invoke(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 658
def invoke(index)
  @menu.invoke(index)
end
            
value() click to toggle source
 
               # File tk/lib/tk/menu.rb, line 638
def value
  @variable.value
end
            
value=(val) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 642
def value=(val)
  @variable.value = val
end
            
xposition(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 670
def xposition(index)
  @menu.xposition(index)
end
            
yposition(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 673
def yposition(index)
  @menu.yposition(index)
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.