For Programmers: Free Programming Magazines  


Home > Archive > Tcl > October 2004 > binding to mouse buttons & keyboard









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author binding to mouse buttons & keyboard
Phil Biehl

2004-10-22, 8:56 am

I want to run a proc in response to either the physical keyboard or a
virtual on-screen keyboard. Tis means I need to bind to ButtonPress and
KeyPress. When I try this I get the physical keyboard events just fine but
no response to button clicks. See below:

Why is this not working?

Thanks!
Phil

bind .dialog.t <KeyPress> {
OnKeyPress . %A %K %s
}
bind .dialog.t <KeyRelease> {
OnKeyRelease . %A %K %s
}
bind .dialog.t <ButtonPress> {
OnKeyPress . %A %K %s
}
bind .dialog.t <ButtonRelease> {
OnKeyRelease . %A %K %s
}


Phil Biehl

2004-10-22, 8:57 pm

Bruce,
What you say much good sense. Something I seem to be lacking at the moment.
The .dialog.t window is a text widget that everything winds up go to. After
I read your reply I simply tried clicking on the text window and
low-and-behold it worked as you said.

I will take your advice and use the -command option for each button to do
teh processing I want to do. That method seemse to make the most sense.

Thanks!


"Bruce Hartweg" <bruce-news@hartweg.us> wrote in message
news:HF8ed.4$Sg.0@dfw-service2.ext.ray.com...
>
>
> Phil Biehl wrote:
>
>
> what kind of widget is .dialog.t ?
> keyboard events go to the widget that has focus,
> but button event go to the widget that the
> pointer is over, so if you have buttons that
> are your virtual keyboard, then these are what get
> the mouse event. If they are in fact buttons, you
> don't need to bind to them, just use their -command
> option. The easiest way to make that work would to
> just have your button commands use event generate
> to to create a <KeyPress> event for the currently
> focused window. If your app is all on one screen,
> you can just deliver the event to the top level window
> and it will go to the currently focused window.
> If your app is multiple windows, use the [focus]
> command to determine where to send it.
>
> If you do this, then even widgets that you don't
> have special Key bindings for will still work (i.e.
> typing into a text or entry widget will work as-is
>
> Bruce
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com