summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tk')
-rw-r--r--ext/tk/lib/tk/listbox.rb20
-rw-r--r--ext/tk/lib/tk/text.rb6
2 files changed, 26 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
diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb
index acdc905fe0..c05e3f03ad 100644
--- a/ext/tk/lib/tk/text.rb
+++ b/ext/tk/lib/tk/text.rb
@@ -120,6 +120,12 @@ class TkText<TkTextWin
val
end
+ def clear
+ tk_send_without_enc('delete', "1.0", 'end')
+ self
+ end
+ alias erase clear
+
def _addcmd(cmd)
@cmdtbl.push cmd
end