Here is another problem I can't fix.What works for me is
bind $::w <Control-Left> {p.SwitchTabs "left"; break}
bind $::w <Control-Right> {p.SwitchTabs "right"; break}
The problem is, a treeview usually has the focus. So when I press ><Control-Left> or <Control-Right>, the tree selection changes as
if I had just pressed the bare Left/Right key.
I though "break" was supposed to prevent that. No?
Luc <[email protected]d> schrieb:
Here is another problem I can't fix.
bind $::w <Control-Left> {p.SwitchTabs "left";
break} bind $::w <Control-Right> {p.SwitchTabs "right";
break}
The problem is, a treeview usually has the focus. So when I press ><Control-Left> or <Control-Right>, the tree selection changes as
if I had just pressed the bare Left/Right key.
I though "break" was supposed to prevent that. No?
What works for me is
return -code break
HTH
Helmut
Here is another problem I can't fix.
bind $::w <Control-Left> {p.SwitchTabs "left"; break}
bind $::w <Control-Right> {p.SwitchTabs "right"; break}
The problem is, a treeview usually has the focus. So when I press
<Control-Left> or <Control-Right>, the tree selection changes as
if I had just pressed the bare Left/Right key.
I though "break" was supposed to prevent that. No?
Here is another problem I can't fix.
bind $::w <Control-Left> {p.SwitchTabs "left"; break}
bind $::w <Control-Right> {p.SwitchTabs "right"; break}
The problem is, a treeview usually has the focus. So when I press <Control-Left> or <Control-Right>, the tree selection changes as
if I had just pressed the bare Left/Right key.
I though "break" was supposed to prevent that. No?
--
Luc
Events are delivered to the widget which has the focus, and they are processed in the order given by the [bindtags] command. I pseudocode,
a Tcl script implementing bindings does
foreach tag [bindtags $win] {
uplevel #0 [bind $tag $sequence]
}
By default, a wiget binding tags are, in order, its name, its class,
its nearest toplevel up in the window hierarchy and the "all" tag.
list $win [winfo class $win] [winfo toplevel $win] "all"
In your case, I assume $::w is a toplevel widget, so it comes after
the treeview class tag (Treeview), on which are set all the bindings
that define treeview's default behaviour.
So when your binding fires, the treeview already has changed the
selection. The [break] command only avoids the firing of the "all" tag, should it have any binding set to <Control-Left> or right.
As a workaround, you can try setting a more specific binding on Treeview (untested)
bind Treeview <Control-Left> {# do nothing}
bind Treeview <Control-Right> {# do nothing}
From: Luc <[email protected]d>
Date: Wed May 17 00:33:09 GMT 2023
Subject: I can't "break" a binding
But this works:
bind Treeview <Control-Left> {break}
bind Treeview <Control-Right> {break}
bind Treeview <Control-Left> {p.SwitchTabs "left"; break}
bind Treeview <Control-Right> {p.SwitchTabs "right"; break}
So not only do I have to kill an existing binding, I have to redefine it
even for a specific widget (Treeview) or else it won't work.
On Tue, 16 May 2023 14:52:11 -0300, Emiliano Gavilan wrote:
Events are delivered to the widget which has the focus, and they are
processed in the order given by the [bindtags] command. I pseudocode,
a Tcl script implementing bindings does
foreach tag [bindtags $win] {
uplevel #0 [bind $tag $sequence]
}
By default, a wiget binding tags are, in order, its name, its class,
its nearest toplevel up in the window hierarchy and the "all" tag.
list $win [winfo class $win] [winfo toplevel $win] "all"
In your case, I assume $::w is a toplevel widget, so it comes after
the treeview class tag (Treeview), on which are set all the bindings
that define treeview's default behaviour.
So when your binding fires, the treeview already has changed the
selection. The [break] command only avoids the firing of the "all" tag,
should it have any binding set to <Control-Left> or right.
As a workaround, you can try setting a more specific binding on Treeview
(untested)
bind Treeview <Control-Left> {# do nothing}
bind Treeview <Control-Right> {# do nothing}
It works. Thank you!
However,
This doesn't work:
bind Treeview <Control-Left> {break}
bind Treeview <Control-Right> {break}
bind $::w <Control-Left> {p.SwitchTabs "left"; break}
bind $::w <Control-Right> {p.SwitchTabs "right"; break}
But this works:
bind Treeview <Control-Left> {break}
bind Treeview <Control-Right> {break}
bind Treeview <Control-Left> {p.SwitchTabs "left"; break}
bind Treeview <Control-Right> {p.SwitchTabs "right"; break}
bind Treeview <Control-Left> {p.SwitchTabs "left"; break}
bind Treeview <Control-Right> {p.SwitchTabs "right"; break}
So not only do I have to kill an existing binding, I have to redefine it
even for a specific widget (Treeview) or else it won't work.
Seeing that I intend to let the user select their own keyboard
combinations for every action, I suspect this is going to be a bit of
a lot of headache for me.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (3 / 13) |
| Uptime: | 28:02:16 |
| Calls: | 12,107 |
| Calls today: | 7 |
| Files: | 15,006 |
| Messages: | 6,518,228 |