From: Hidetoshi NAGAI <
[email protected]>
Subject: Re: get active selection from tk iwidgets radiobox
Date: Mon, 18 Feb 2008 12:39:53 +0900
Message-ID: said:
Please give me more two or three days.
Sorry, too late. The following is the patch.
'Tk::Iwidgets::Radiobox#get_tag' (and 'Radiobox#get) returns
the tag name of the selected button.
'Tk::Iwidgets::Radiobox#get_obj' returns the component object
which denotes the selected button.
You can get the tag name of the button component object
by 'name' method of the object.
The patch includes bug fix of Tk::Iwidgets::Checkbox too.
'Tk::Iwidgets::Checkbox#get_tags' returns tag name list of
selected buttons, and 'Tk::Iwidgets::Checkbox#get_objs'
returns component list of selected buttons.
'Tk::Iwidgets::Checkbox#get(idx)' returns status (boolean
value) of the checkbutton 'idx'.
And 'Tk::Iwidgets::Checkbox#get' (with no argument) returns
the same result of 'Tk::Iwidgets::Checkbox#get_tags'
(it follows the feature of the Tcl/Tk function).
Index: ext/tk/lib/tkextlib/iwidgets/radiobox.rb
===================================================================
--- ext/tk/lib/tkextlib/iwidgets/radiobox.rb (revision 15558)
+++ ext/tk/lib/tkextlib/iwidgets/radiobox.rb (working copy)
@@ -85,12 +85,15 @@
self
end
- def get(idx)
- simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
- Tk::Itk::Component.id2obj(self, id)
- }
+ def get_tag
+ ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag
end
+ alias get get_tag
+ def get_obj
+ (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil
+ end
+
def index(idx)
number(tk_call(@path, 'index', tagid(idx)))
end
Index: ext/tk/lib/tkextlib/iwidgets/checkbox.rb
===================================================================
--- ext/tk/lib/tkextlib/iwidgets/checkbox.rb (revision 15558)
+++ ext/tk/lib/tkextlib/iwidgets/checkbox.rb (working copy)
@@ -85,12 +85,24 @@
self
end
- def get(idx)
- simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
+ def get_tags
+ simplelist(tk_call_without_enc(@path, 'get'))
+ end
+
+ def get_objs
+ simplelist(tk_call_without_enc(@path, 'get')).collect{|id|
Tk::Itk::Component.id2obj(self, id)
}
end
+ def get(idx=nil)
+ if idx
+ bool(tk_call_without_enc(@path, 'get', index(idx)))
+ else
+ get_tags
+ end
+ end
+
def index(idx)
number(tk_call(@path, 'index', tagid(idx)))
end
Index: ext/tk/lib/tkextlib/itk/incr_tk.rb
===================================================================
--- ext/tk/lib/tkextlib/itk/incr_tk.rb (revision 15558)
+++ ext/tk/lib/tkextlib/itk/incr_tk.rb (working copy)
@@ -156,7 +156,7 @@
master = master.to_s
end
return id unless ComponentID_TBL.key?(master)
- (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id
+ (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id
end
def self.new(master, component=nil)