Home > Archive > Tcl > July 2007 > BWidget <<TreeSelect>> + keyboard navigation
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 |
BWidget <<TreeSelect>> + keyboard navigation
|
|
| Kevin Walzer 2007-07-31, 8:11 am |
| I'm having problems with a BWidget Tree in one of my applications--it
doesn't seem to fire the <<TreeSelect>> virtual event when the arrow key
is pressed, either up or down. I'm binding a command to this event, so I
have to get this working.
This is typical of what I've tried:
bind $Tree <KeyPress-Up> <<TreeSelect>>
Doesn't work.
Do I need to do something with [event generate] here? Has anyone found a
way to implement this? I'm having some difficulty getting the syntax right.
Thanks for any pointers,
Kevin
| |
| Bryan Oakley 2007-07-31, 7:13 pm |
| Kevin Walzer wrote:
> I'm having problems with a BWidget Tree in one of my applications--it
> doesn't seem to fire the <<TreeSelect>> virtual event when the arrow key
> is pressed, either up or down. I'm binding a command to this event, so I
> have to get this working.
>
> This is typical of what I've tried:
>
> bind $Tree <KeyPress-Up> <<TreeSelect>>
>
> Doesn't work.
>
> Do I need to do something with [event generate] here? Has anyone found a
> way to implement this? I'm having some difficulty getting the syntax right.
No surprise. Look at the documentation for bind and you'll see that
third argument should be the name of a script. Unless you have a
procedure named <<TreeSelect>> it won't work (though, it should throw an
error if the binding is being processed).
So first, you need to generate the virtual event on the keypress like so:
bind $Tree <KeyPress-Up> [list event generate $Tree <<TreeSelect>>]
Second, for this to work the tree widget has to have keyboard focus. I
don't recall off hand if the BWidget sets focus on a mouse click or not.
You can always add that binding yourself, or simply set the focus to the
tree when your application starts up.
Finally, if you have a binding on key-up, realize that that binding will
fire before the tree's class binding, and it's likely that the class
binding is where the tree's notion of what is selected is updated.
--
Bryan Oakley
http://www.tclscripting.com
|
|
|
|
|