Re: Listbox key bindings not working as expected
Jeff Hobbs <[email protected]> Fri, 13 Aug 2010 10:21:39 -0700
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
On 13/08/2010 2:31 AM, Rainer J.H. Brandt wrote:
>> key bindings will work only when keyboard focus is on the widget. Try setting focus like this
>>
>> use Tk;
>> $mw = MainWindow->new();
>> $lb = $mw->Listbox()->pack();
>> $lb->insert('end', 1..5);
>>
>> $lb->focus();
>>
>> MainLoop;
>
> Thanks, your suggestion works.
> However, I'm astonished. Clicking on the widget with the mouse
> doesn't give it keyboard focus? I've never seen a GUI that behaved
> like that. Well, I must have seen it, but haven't noticed it in 14
> years of programming and using Perl/Tk on a daily basis...
If you want to have listboxes take focus, you can extend the class
binding to Listbox on <1> that adds focus. Also note that Tk 8.5 does
correct this oversight with said class binding as default.
Jeff
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk