Class: TkMenu

Class | TkMenu
In: | tk/lib/tk/menu.rb
Parent: | TkWindow

### Methods

activate add add_cascade add_checkbutton add_command add_radiobutton add_separator delete index insert invoke menutype new_menuspec popup post postcascade postcommand set_focus tagid tearoffcommand unpost yposition

### Included Modules

TkMenuEntryConfig

### Constants

TkCommandNames | = | ['menu'.freeze].freeze
WidgetClassName | = | 'Menu'.freeze

### Public Class methods

new_menuspec(menu_spec, parent = nil, tearoff = false, keys = nil)

[Source]

    # File tk/lib/tk/menu.rb, line 72
      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)

[Source]

    # File tk/lib/tk/menu.rb, line 95
      def activate(index)
        tk_send_without_enc('activate', _get_eval_enc_str(index))
        self
      end

add(type, keys=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 99
      def add(type, keys=nil)
        tk_send_without_enc('add', type, *hash_kv(keys, true))
        self
      end

add_cascade(keys=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 103
      def add_cascade(keys=nil)
        add('cascade', keys)
      end

add_checkbutton(keys=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 106
      def add_checkbutton(keys=nil)
        add('checkbutton', keys)
      end

add_command(keys=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 109
      def add_command(keys=nil)
        add('command', keys)
      end

add_radiobutton(keys=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 112
      def add_radiobutton(keys=nil)
        add('radiobutton', keys)
      end

add_separator(keys=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 115
      def add_separator(keys=nil)
        add('separator', keys)
      end

delete(first, last=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 130
      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)

[Source]

    # File tk/lib/tk/menu.rb, line 118
      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)

[Source]

    # File tk/lib/tk/menu.rb, line 125
      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)

[Source]

    # File tk/lib/tk/menu.rb, line 122
      def invoke(index)
        _fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
      end

menutype(index)

[Source]

    # File tk/lib/tk/menu.rb, line 167
      def menutype(index)
        tk_send_without_enc('type', _get_eval_enc_str(index))
      end

popup(x, y, index=nil)

[Source]

    # File tk/lib/tk/menu.rb, line 139
      def popup(x, y, index=nil)
        if index
          tk_call_without_enc('tk_popup', path, x, y,
                              _get_eval_enc_str(index))
        else
          tk_call_without_enc('tk_popup', path, x, y)
        end
        self
      end

post(x, y)

[Source]

    # File tk/lib/tk/menu.rb, line 148
      def post(x, y)
        _fromUTF8(tk_send_without_enc('post', x, y))
      end

postcascade(index)

[Source]

    # File tk/lib/tk/menu.rb, line 151
      def postcascade(index)
        tk_send_without_enc('postcascade', _get_eval_enc_str(index))
        self
      end

postcommand(cmd=Proc.new)

[Source]

    # File tk/lib/tk/menu.rb, line 155
      def postcommand(cmd=Proc.new)
        configure_cmd 'postcommand', cmd
        self
      end

set_focus()

[Source]

    # File tk/lib/tk/menu.rb, line 159
      def set_focus
        tk_call_without_enc('tk_menuSetFocus', path)
        self
      end

tagid(id)

[Source]

    # File tk/lib/tk/menu.rb, line 90
      def tagid(id)
        #id.to_s
        _get_eval_string(id)
      end

tearoffcommand(cmd=Proc.new)

[Source]

    # File tk/lib/tk/menu.rb, line 163
      def tearoffcommand(cmd=Proc.new)
        configure_cmd 'tearoffcommand', cmd
        self
      end

unpost()

[Source]

    # File tk/lib/tk/menu.rb, line 170
      def unpost
        tk_send_without_enc('unpost')
        self
      end

yposition(index)

[Source]

    # File tk/lib/tk/menu.rb, line 174
      def yposition(index)
        number(tk_send_without_enc('yposition', _get_eval_enc_str(index)))
      end

[Validate]