From: Markus Liebelt Date: 2005-07-02T21:20:45+09:00 Subject: Re: Problem in binding IWidget combobox to event Hello Hidetoshi, exactly what I was looking for. Seems a lot cleaner and more fitting to MVC what I was looking for. Thank you a lot Markus On Tue, 28 Jun 2005 17:52:32 +0200, Hidetoshi NAGAI wrote: > From: "Markus Liebelt" > Subject: Problem in binding IWidget combobox to event > Date: Tue, 28 Jun 2005 23:05:40 +0900 > Message-ID: >> I managed lately to include an iwidget combobox in a UI I have written. >> If >> normally used (by poking around with the mouse) everything works fine. >> What I cannot manage if the user is using the keyboard. > (snip) >> If you open that application, and drop down with the mouse and select >> with >> the mouse, you see on $stdout your selection. If you open in any way, >> but >> select then by using TAB (focus goes to drop down list) and ENTER, your >> selection goes into the combo box, but is not reflected in the $stdout. > > It seems a specification limit of an iwidget combobox. > >> What do I have to get a binding for the different possibilities to use >> the >> combo box? Or is there even an easier way, eg. by using a binding to the >> variable that lays behind the combo box? > > TkVariable#trace will be able to help you. Possibly, that is more > simple than getting the listbox component and binding to it. > For example, > ----------------------------------------------------------- > class Ex_Combo > def build_form(root) > frame = self.create_frame(:form, root) > var = TkVariable.new > cb1 = Tk::Iwidgets::Combobox.new(frame, #:labeltext=>'Example:', > #:selectioncommand=>proc{puts cb1.get_curselection; > $stdout.flush}, > :textvariable=>var, > :editable=>false) > var.trace('w'){ > # This is called twice when selecting an item. > # One is when clearing the entry and the another is when setting > # a new value to it. > # The following check is the one to ignore clearing step. > unless (val = var.value).empty? > puts val > $stdout.flush > end > } > cb1.insert_list('end', *['First entry','Second entry','Third > entry']) > cb1.grid('row'=>0, 'column'=>0, 'sticky'=>'news') > frame.pack('side'=>'left', 'expand'=>'yes') > end > end > ----------------------------------------------------------- -- Markus Liebelt; markus.liebelt@online.de