Re: BWidget <<TreeSelect>> + keyboard navigation



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
.



Relevant Pages

  • Re: Binding.Format event with ComboBox
    ... I did find that the SelectedValue Binding does fire ... but it does not fire when an item is selected. ... > Private Sub Form1_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Tk button binding strange problem
    ... >:which prevents the Button class binding from restoring the relief. ... the default bindtags are widget widgetClass topLevelOfWidget all ...
    (comp.lang.tcl)
  • Re: bind question - is there a not modifier?
    ... your problem is that you have a binding ... on a canvas item and a slightly different binding on the canvas. ... canvas man page documents the fact that both of these bindings will fire. ... And I now understand the paragraph in bind on multiple ...
    (comp.lang.tcl)
  • Re: Native English speakers wanted
    ... Of course It is possible to do that with record changing event, ... > always fire, ... > when I changed rows on the binding context and rarely if I changed a value ... > binding context as far as I'm concerned. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ComboBox - How to stop firing Select Index Event on Load
    ... > Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ... > I am binding a dataset to a ComboBoxwhich causes the ... > don't want to fire this code when binding the data to the combobox. ...
    (microsoft.public.dotnet.languages.vb.controls)