Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

One man's constant is another man's variable. -- A. J. Perlis


devel / comp.lang.tcl / I can't "break" a binding

SubjectAuthor
* I can't "break" a bindingLuc
+* I can't "break" a bindingHelmut Giese
|`- I can't "break" a bindingLuc
+- I can't "break" a bindingAndreas Leitgeb
`* I can't "break" a bindingEmiliano Gavilan
 `* I can't "break" a bindingLuc
  `- I can't "break" a bindingRich

1
I can't "break" a binding

<20230514143811.1a3f89d5@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11517&group=comp.lang.tcl#11517

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: I can't "break" a binding
Date: Sun, 14 May 2023 14:38:11 -0300
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20230514143811.1a3f89d5@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="ac31424efa986911df963e818a679519";
logging-data="2838090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/L/m3F9lSwiyO7fzRextX6HZoMvaYoOAo="
Cancel-Lock: sha1:ABWnKzkLqLo6F9g0wDqgkRkW7iE=
 by: Luc - Sun, 14 May 2023 17:38 UTC

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

Re: I can't "break" a binding

<s4926ihlrgkqusunbk8fr4j81kfr5utmgc@4ax.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11518&group=comp.lang.tcl#11518

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: Re: I can't "break" a binding
Date: Sun, 14 May 2023 20:13:17 +0200
Organization: ratiosoft
Lines: 16
Message-ID: <s4926ihlrgkqusunbk8fr4j81kfr5utmgc@4ax.com>
References: <20230514143811.1a3f89d5@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="279ecf2955c2699377e2c2022f7276ff";
logging-data="2844496"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vtSBGITdKkmk5VeWAGrKX"
Cancel-Lock: sha1:x4sdJGjMJrA2xppSWtiMDgeRECc=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
 by: Helmut Giese - Sun, 14 May 2023 18:13 UTC

Luc <luc@sep.invalid> 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

Re: I can't "break" a binding

<20230514191911.11bb2b8c@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11520&group=comp.lang.tcl#11520

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: I can't "break" a binding
Date: Sun, 14 May 2023 19:19:11 -0300
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <20230514191911.11bb2b8c@lud1.home>
References: <20230514143811.1a3f89d5@lud1.home>
<s4926ihlrgkqusunbk8fr4j81kfr5utmgc@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="401c6b4514d994302f78181a3b8bcdb8";
logging-data="2896777"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XmW2fTV/rSkuuZyw25SmAWzYM1sIL5Ec="
Cancel-Lock: sha1:inFXOMml+1ruhaZsxy4QOfBQcjs=
 by: Luc - Sun, 14 May 2023 22:19 UTC

On Sun, 14 May 2023 20:13:17 +0200, Helmut Giese wrote:

> Luc <luc@sep.invalid> 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

Thanks, but it doesn't work for me. The problem remains.

--
Luc
>>

Re: I can't "break" a binding

<slrnu6422u.4ls.avl@logic.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11527&group=comp.lang.tcl#11527

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: avl@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: I can't "break" a binding
Date: Mon, 15 May 2023 10:24:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <slrnu6422u.4ls.avl@logic.at>
References: <20230514143811.1a3f89d5@lud1.home>
Reply-To: avl@logic.at
Injection-Date: Mon, 15 May 2023 10:24:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="816d6959050300cf36ad599b3de29a69";
logging-data="3186773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eGXOgW91g+bjQGOZv9le7"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:UjrbiFxxO2bel1xMgZ0BY/XcHaU=
 by: Andreas Leitgeb - Mon, 15 May 2023 10:24 UTC

Luc <luc@sep.invalid> wrote:
> 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?

The other reply about "return -code break" would have been relevant
only, when called from the body of a procedure that would be called
from the binding... e.g. if procedure p.SwitchTabs were yours,
then from within that you'd do the return -code break.

If break (directly in the binding) doesn't work for you, then the
problem is elsewhere...

First check would be, whether your break is even reached. make the
binding look like: {p.SwitchTabs "left"; puts checkpoint; break}
and check, if you get to see the checkpoint in the console.
if you don't see it, put a second puts checkpoint2 before p.SwitchTabs.
If you then see checkpoint2, but not checkpoint, then the procedure
p.SwitchTabs seems to do some other return -code ... trick that would
cause your break to not be executed.

If you see the checkpoint, (or don't see the checkpoint2) then you need
to check the "bindtags" for the widget $::w maybe in that sequence
some other thing fires first, and already handes Right/Left, before it
gets to your binding.

Another hint: carefully read the documentation for "bindtags".

Re: I can't "break" a binding

<20230516145211.9259b3d7ca0dbb24ee849495@gmail.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11545&group=comp.lang.tcl#11545

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: emilianogavilan@gmail.com (Emiliano Gavilan)
Newsgroups: comp.lang.tcl
Subject: Re: I can't "break" a binding
Date: Tue, 16 May 2023 14:52:11 -0300
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <20230516145211.9259b3d7ca0dbb24ee849495@gmail.com>
References: <20230514143811.1a3f89d5@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="d89ef693d6c818545fb6e6e245667c6a";
logging-data="3739442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+amDLBcUihtld9IqCppKwYz2Uk3c5c7QY="
Cancel-Lock: sha1:UGTgoaKosjOPF5S4N7YPa+WrnaA=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Emiliano Gavilan - Tue, 16 May 2023 17:52 UTC

On Sun, 14 May 2023 14:38:11 -0300
Luc <luc@sep.invalid> wrote:

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

--
Emiliano Gavilan <emilianogavilan@gmail.com>

Re: I can't "break" a binding

<20230516213309.5d61135d@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11546&group=comp.lang.tcl#11546

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: I can't "break" a binding
Date: Tue, 16 May 2023 21:33:09 -0300
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <20230516213309.5d61135d@lud1.home>
References: <20230514143811.1a3f89d5@lud1.home>
<20230516145211.9259b3d7ca0dbb24ee849495@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="22a4e9efe9f239945f486fba6b1eb609";
logging-data="3821612"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19M9FDOXLRHMBI4r6sbsU4JBJunyjVF4/k="
Cancel-Lock: sha1:KP5PKTMRKl7dRNFHPuXCAgDQ/Vc=
 by: Luc - Wed, 17 May 2023 00:33 UTC

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}

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.

--
Luc
>>

Re: I can't "break" a binding

<u41dc7$3oso4$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=11548&group=comp.lang.tcl#11548

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: I can't "break" a binding
Date: Wed, 17 May 2023 02:15:35 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <u41dc7$3oso4$1@dont-email.me>
References: <20230514143811.1a3f89d5@lud1.home> <20230516145211.9259b3d7ca0dbb24ee849495@gmail.com> <20230516213309.5d61135d@lud1.home>
Injection-Date: Wed, 17 May 2023 02:15:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f741809d492d61fcd9f153c375ca143e";
logging-data="3961604"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jjLzRa+SWaHWBXIeKzvD4"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:aueRnjgU8/aOrXBDXLHcJ76GCrc=
 by: Rich - Wed, 17 May 2023 02:15 UTC

Luc <luc@sep.invalid> wrote:
> 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}

Changing the binding to 'break' is *very* different from changing it to
a 'comment' (which does nothing). Alternately, an empty string
completely removes the existing binding.

> bind $::w <Control-Left> {p.SwitchTabs "left"; break}
> bind $::w <Control-Right> {p.SwitchTabs "right"; break}

Because the bindtags execute first, and because you changed to 'break',
you prevented your binding on $::w from firing, because the 'break' in
the bindtags stopped further execution of additional bindings for the event.

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

Your second two replace your first two, so the above is exactly
identical to this:

> bind Treeview <Control-Left> {p.SwitchTabs "left"; break}
> bind Treeview <Control-Right> {p.SwitchTabs "right"; break}

Which means you have replaced the existing default binding with your
own. And without a 'break' messing things up, your bindings get
executed.

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

Redefining it is exactly "killing an existing binding". There's no
'two step' process here. You don't have to 'first kill' then
'redefine'. Just bind a new script (with no + prefix), and that
replaces the old script.

Another poster in a different thread suggested you "carefully read the
bind manpage" -- you really *do* need to do so.

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

Building anything that is super flexible (such as user selection of
their own keyboard bindings) is always going to be a "bit of a headache
for you".


devel / comp.lang.tcl / I can't "break" a binding

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor