2
# tkextlib/iwidgets/combobox.rb
3
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7
require 'tkextlib/iwidgets.rb'
11
class Combobox < Tk::Iwidgets::Entryfield
16
class Tk::Iwidgets::Combobox
17
TkCommandNames = ['::iwidgets::combobox'.freeze].freeze
18
WidgetClassName = 'Combobox'.freeze
19
WidgetClassNames[WidgetClassName] = self
22
super() << 'completion' << 'dropdown' << 'editable' << 'unique'
24
private :__boolval_optkeys
26
def clear(component=None)
27
tk_call(@path, 'clear', component)
31
def delete_list(first, last=None)
32
tk_call(@path, 'delete', 'list', first, last)
36
def delete_entry(first, last=None)
37
tk_call(@path, 'delete', 'entry', first, last)
41
def get_list_contents(index)
42
tk_call(@path, 'get', index)
45
def insert_list(idx, *elems)
46
tk_call(@path, 'insert', 'list', idx, *elems)
50
def insert_entry(idx, *elems)
51
tk_call(@path, 'insert', 'entry', idx, *elems)
57
tk_send_without_enc('size').to_i
60
tk_send_without_enc('see', index)
63
def selection_anchor(index)
64
tk_send_without_enc('selection', 'anchor', index)
67
def selection_clear(first, last=None)
68
tk_send_without_enc('selection', 'clear', first, last)
71
def selection_includes(index)
72
bool(tk_send_without_enc('selection', 'includes', index))
74
def selection_set(first, last=None)
75
tk_send_without_enc('selection', 'set', first, last)
79
# scrolledlistbox methods
81
tk_call(@path, 'getcurselection')
84
tk_call(@path, 'justify', dir)
88
# see 'lsort' man page about params
90
tk_call(@path, 'sort', '-command', proc(&b), *params)
92
tk_call(@path, 'sort', *params)
97
tk_call(@path, 'sort', 'ascending')
101
tk_call(@path, 'sort', 'descending')