Re: BWidget <<TreeSelect>> + keyboard navigation



Bryan Oakley wrote:

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>>]

I played around with this a bit, and it didn't work. Then I remembered that custom bindings on BWidgets sometimes need to be set on the underling canvas, like so:

bind $Tree.c <KeyPress-Up> [list event generate $Tree <<TreeSelect>>]

This works, sort of. It triggers the <<TreeSelect>> event, and the command I've bound to <<TreeSelect>>. However, it won't release the selection; keyboard navigation no longer works.

After looking at the "event" and "bind" man pages a bit more, I realized I needed to add a "+" to the command:

+event generate...

And trying the syntax in this fashion:

bind $Tree.c <KeyPress-Up> [list +event generate $Tree <<TreeSelect>>]

This works the way it's supposed to. It appends the <<TreeSelect>> event to the keyboard navigation already provided by the <KeyPress-Up> binding, rather than replacing the existing bindings.

Thanks for the clarification.
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
.