In Files

  • tk/lib/tk/menu.rb
  • tk/lib/tk/menuspec.rb

Class/Module Index [+]

Quicksearch

Tk::Menu

Public Class Methods

new_menuspec(menu_spec, parent = nil, tearoff = false, keys = nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 76
def self.new_menuspec(menu_spec, parent = nil, tearoff = false, keys = nil)
  if parent.kind_of?(Hash)
    keys = _symbolkey2str(parent)
    parent = keys.delete('parent')
    tearoff = keys.delete('tearoff')
  elsif tearoff.kind_of?(Hash)
    keys = _symbolkey2str(tearoff)
    tearoff = keys.delete('tearoff')
  elsif keys
    keys = _symbolkey2str(keys)
  else
    keys = {}
  end

  widgetname = keys.delete('widgetname')
  _create_menu(parent, menu_spec, widgetname, tearoff, keys)
end
            

Public Instance Methods

activate(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 99
def activate(index)
  tk_send_without_enc('activate', _get_eval_enc_str(index))
  self
end
            
add(type, keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 103
def add(type, keys=nil)
  tk_send_without_enc('add', type, *hash_kv(keys, true))
  self
end
            
add_cascade(keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 107
def add_cascade(keys=nil)
  add('cascade', keys)
end
            
add_checkbutton(keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 110
def add_checkbutton(keys=nil)
  add('checkbutton', keys)
end
            
add_command(keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 113
def add_command(keys=nil)
  add('command', keys)
end
            
add_radiobutton(keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 116
def add_radiobutton(keys=nil)
  add('radiobutton', keys)
end
            
add_separator(keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 119
def add_separator(keys=nil)
  add('separator', keys)
end
            
clone_menu(*args) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 123
def clone_menu(*args)
  if args[0].kind_of?(TkWindow)
    parent = args.shift
  else
    parent = self
  end

  if args[0].kind_of?(String) || args[0].kind_of?(Symbol) # menu type
    type = args.shift
  else
    type = None # 'normal'
  end

  if args[0].kind_of?(Hash)
    keys = _symbolkey2str(args.shift)
  else
    keys = {}
  end

  parent = keys.delete('parent') if keys.has_key?('parent')
  type = keys.delete('type') if keys.has_key?('type')

  if keys.empty?
    Tk::MenuClone.new(self, parent, type)
  else
    Tk::MenuClone.new(self, parent, type, keys)
  end
end
            
delete(first, last=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 164
def delete(first, last=nil)
  if last
    tk_send_without_enc('delete', _get_eval_enc_str(first),
                        _get_eval_enc_str(last))
  else
    tk_send_without_enc('delete', _get_eval_enc_str(first))
  end
  self
end
            
index(idx) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 152
def index(idx)
  ret = tk_send_without_enc('index', _get_eval_enc_str(idx))
  (ret == 'none')? nil: number(ret)
end
            
insert(index, type, keys=nil) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 159
def insert(index, type, keys=nil)
  tk_send_without_enc('insert', _get_eval_enc_str(index),
                      type, *hash_kv(keys, true))
  self
end
            
invoke(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 156
def invoke(index)
  _fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
end
            
post(x, y) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 182
def post(x, y)
  _fromUTF8(tk_send_without_enc('post', x, y))
end
            
postcascade(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 185
def postcascade(index)
  tk_send_without_enc('postcascade', _get_eval_enc_str(index))
  self
end
            
postcommand(cmd=Proc.new) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 189
def postcommand(cmd=Proc.new)
  configure_cmd 'postcommand', cmd
  self
end
            
set_focus() click to toggle source
 
               # File tk/lib/tk/menu.rb, line 193
def set_focus
  tk_call_without_enc('tk_menuSetFocus', path)
  self
end
            
tagid(id) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 94
def tagid(id)
  #id.to_s
  _get_eval_string(id)
end
            
tearoffcommand(cmd=Proc.new) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 197
def tearoffcommand(cmd=Proc.new)
  configure_cmd 'tearoffcommand', cmd
  self
end
            
unpost() click to toggle source
 
               # File tk/lib/tk/menu.rb, line 204
def unpost
  tk_send_without_enc('unpost')
  self
end
            
xposition(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 208
def xposition(index)
  number(tk_send_without_enc('xposition', _get_eval_enc_str(index)))
end
            
yposition(index) click to toggle source
 
               # File tk/lib/tk/menu.rb, line 211
def yposition(index)
  number(tk_send_without_enc('yposition', _get_eval_enc_str(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.