non-mouse event binding in Listbox doesn't work? 
Author Message
 non-mouse event binding in Listbox doesn't work?

Hello,

Can anyone tell me why when I try to bind a <KeyPress> or <Return> or
<Up> or <Down to a Listbox in either tcl/tk (7.6/4.2) or perl/Tk
nothing happens?  I can bind a <1> or <Double-1> without any problems.
It seems as though only mouse events can be bound... should this be
happening?

--
Rob Urban
Digital Equipment GmbH
Freischuetzstr. 91
81927 Muenchen
Germany



Sun, 28 Nov 1999 03:00:00 GMT  
 non-mouse event binding in Listbox doesn't work?



Quote:
>Can anyone tell me why when I try to bind a <KeyPress> or <Return> or
><Up> or <Down to a Listbox in either tcl/tk (7.6/4.2) or perl/Tk

It is likely that you do not have focus in the listbox, which is
required for key events to go to the right place.  You can either
Tab the focus in or set it explicitly with [focus .listbox].

Note that some widgets will assume focus once a button event occurs
in them (like the entry or text widgets), but that is not true of
the listbox widget.

--

  Software Engineer, Oregon R&D        office: 541.683.7891
  CADIX International, Inc.            fax:    541.683.8325
             URL: http://www.cs.uoregon.edu/~jhobbs/



Sun, 28 Nov 1999 03:00:00 GMT  
 non-mouse event binding in Listbox doesn't work?

Quote:

> Hello,

> Can anyone tell me why when I try to bind a <KeyPress> or <Return> or
> <Up> or <Down to a Listbox in either tcl/tk (7.6/4.2) or perl/Tk
> nothing happens?  I can bind a <1> or <Double-1> without any problems.
> It seems as though only mouse events can be bound... should this be
> happening?

Perhaps the keyboard focus is on some other widget. Does the listbox
have a dark border around it? Here's an example showing that it works:

    listbox .foo
    pack .foo
    .foo insert end "red"
    .foo insert end "orange"
    .foo insert end "green"
    .foo insert end "blue"

    bind .foo <Any-KeyPress> {bell; puts "boink!"}
    focus .foo

One solution would be to add a binding for ButtonPress-1 to set the
focus to the listbox.

--

Software Engineer                http://www1.clearlight.com/~oakley/
Healthcare Communications, Inc.  http://www.healthcare.com/



Sun, 28 Nov 1999 03:00:00 GMT  
 non-mouse event binding in Listbox doesn't work?



Quote:
> It is likely that you do not have focus in the listbox, which is
> required for key events to go to the right place.  You can either
> Tab the focus in or set it explicitly with [focus .listbox].

That's probably it. thanks.

--
Rob Urban
Digital Equipment GmbH
Freischuetzstr. 91
81927 Muenchen
Germany



Sun, 19 Dec 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. binding non-X events in listbox

2. Binding mouse event to a canvas

3. help binding mouse events to canvas

4. Event Log Reporting - Doesn't Work

5. $canvas->bind etc doesn't work

6. Changing focus order with bind() doesn't work

7. How to bind 'Back Space' event

8. acting on non event-oriented events

9. bind event happens before 'active' index set in Listbox

10. Directory handling script works and doesn't work

11. ODBC.PM and sql's Like doesn't work

12. UNIVERSAL doesn't work how I'd expect

 

 
Powered by phpBB® Forum Software