diff options
Diffstat (limited to 'ext/tk/lib/tk/listbox.rb')
-rw-r--r-- | ext/tk/lib/tk/listbox.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb index 70df0ad685..d642ba2f09 100644 --- a/ext/tk/lib/tk/listbox.rb +++ b/ext/tk/lib/tk/listbox.rb @@ -77,6 +77,26 @@ class TkListbox<TkTextWin tk_send_without_enc('index', index).to_i end + def value + get('0', 'end') + end + + def value= (vals) + unless vals.kind_of?(Array) + fail ArgumentError, 'an Array is expected' + end + tk_send_without_enc('delete', '0', 'end') + tk_send_without_enc('insert', '0', + *(vals.collect{|v| _get_eval_enc_str(v)})) + vals + end + + def clear + tk_send_without_enc('delete', '0', 'end') + self + end + alias erase clear + =begin def itemcget(index, key) case key.to_s |