Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Now here's something you're really going to like!" -- Rocket J. Squirrel


devel / comp.lang.tcl / Re: button stuck after continuous depression for a few seconds (??)

SubjectAuthor
* button stuck after continuous depression for a few seconds (??)xol odho
`* Re: button stuck after continuous depression for a few seconds (??)saitology9
 `* Re: button stuck after continuous depression for a few seconds (??)Ralf Fassel
  `* Re: button stuck after continuous depression for a few seconds (??)Ralf Fassel
   `* Re: button stuck after continuous depression for a few seconds (??)xol odho
    `* Re: button stuck after continuous depression for a few seconds (??)Erik Leunissen
     +- Re: button stuck after continuous depression for a few seconds (??)xol odho
     `* Re: button stuck after continuous depression for a few seconds (??)xol odho
      `- Re: button stuck after continuous depression for a few seconds (??)Erik Leunissen

1
button stuck after continuous depression for a few seconds (??)

<5b387371-6705-4235-becf-779035621f04n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19962&group=comp.lang.tcl#19962

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:5768:0:b0:496:aa1a:edf9 with SMTP id r8-20020ad45768000000b00496aa1aedf9mr5639712qvx.115.1661466922274;
Thu, 25 Aug 2022 15:35:22 -0700 (PDT)
X-Received: by 2002:aca:281a:0:b0:344:cafe:fba7 with SMTP id
26-20020aca281a000000b00344cafefba7mr459769oix.194.1661466921992; Thu, 25 Aug
2022 15:35:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 25 Aug 2022 15:35:21 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=201.231.246.253; posting-account=DnakAAoAAAA9ZZlBDSXHBE9MWv_A1hHG
NNTP-Posting-Host: 201.231.246.253
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
Subject: button stuck after continuous depression for a few seconds (??)
From: xolodho@gmail.com (xol odho)
Injection-Date: Thu, 25 Aug 2022 22:35:22 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 19
 by: xol odho - Thu, 25 Aug 2022 22:35 UTC

Hi everyone. I'm learning some Tcl and Tk basics, enjoying what I'm
learning it so far.

I just found out an oddity about the classic Tk buttons: if you focus a
button and hold down spacebar (so that it's depressed continuously) for a
few seconds and then release spacebar, then it seems to remain stuck in
the depressed state.

Try it like this: open `wish`, then `pack [button .b1 -text hello]`, now
on the toplevel with the button hit tab to focus the button, now hold down
spacebar for at least four seconds, and release. Is it stuck? If so, why
does this happen...

This tickles my curiosity. It doesn't seem to happen with ttk::button
(instead it hangs stuck for a while and then reverts back to normal).

I confirm I get this behavior on the following platforms:
Windows XP, Iron Tcl, Tk 8.6.7
Windows 7, BAWT Tcl, Tk 8.6.11
ArchLinux, distro's default Tcl/Tk on X11, Tk 8.6.12

Re: button stuck after continuous depression for a few seconds (??)

<te912m$kc9$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19963&group=comp.lang.tcl#19963

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!a5rWVvs5S5ZXUwkNcVnRMw.user.46.165.242.91.POSTED!not-for-mail
From: saitology9@gmail.com
Newsgroups: comp.lang.tcl
Subject: Re: button stuck after continuous depression for a few seconds (??)
Date: Thu, 25 Aug 2022 19:36:53 -0400
Organization: Aioe.org NNTP Server
Message-ID: <te912m$kc9$1@gioia.aioe.org>
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="20873"; posting-host="a5rWVvs5S5ZXUwkNcVnRMw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.2
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: saitology9@gmail.com - Thu, 25 Aug 2022 23:36 UTC

On 8/25/22 6:35 PM, xol odho wrote:
> Hi everyone. I'm learning some Tcl and Tk basics, enjoying what I'm
> learning it so far.
>
> I just found out an oddity about the classic Tk buttons: if you focus a
> button and hold down spacebar (so that it's depressed continuously) for a
> few seconds and then release spacebar, then it seems to remain stuck in
> the depressed state.
>

It is not stuck. You can configure it with a -command option to print
something to the console to confirm. As to why it appears that way,
since no mouse movement/click was involved, it still has the focus and
it shows this by displaying it in the "depressed" state.

Re: button stuck after continuous depression for a few seconds (??)

<ygawnavs7pb.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19967&group=comp.lang.tcl#19967

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: button stuck after continuous depression for a few seconds (??)
Date: Fri, 26 Aug 2022 10:57:36 +0200
Lines: 22
Message-ID: <ygawnavs7pb.fsf@akutech.de>
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
<te912m$kc9$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net ppnKtZUDakF6DRjKrX6rRgV+A9Yf4v/716lh2s15unjSdS3tA=
Cancel-Lock: sha1:LucIRhhRbCJ4QpOYzCYiyoupNv0= sha1:XQTQtwpdnUJjRHuEQqWFUYgqXGs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Fri, 26 Aug 2022 08:57 UTC

* saitology9@gmail.com
| On 8/25/22 6:35 PM, xol odho wrote:
| > Hi everyone. I'm learning some Tcl and Tk basics, enjoying what I'm
| > learning it so far.
| >
| > I just found out an oddity about the classic Tk buttons: if you focus a
| > button and hold down spacebar (so that it's depressed continuously) for a
| > few seconds and then release spacebar, then it seems to remain stuck in
| > the depressed state.

Can confirm this in Opensuse 15.3, Tk 8.6.12.

| It is not stuck. You can configure it with a -command option to print
| something to the console to confirm. As to why it appears that way,
| since no mouse movement/click was involved, it still has the focus and
| it shows this by displaying it in the "depressed" state.

Seems like the Button-release-event which reconfigures the 'raised'
relief gets lost somehow. The button is fully functional, reacts to
mouse and keyboard, just the relief is 'sunken' instead of 'raised'.

R'

Re: button stuck after continuous depression for a few seconds (??)

<ygasfljs7ay.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19969&group=comp.lang.tcl#19969

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: button stuck after continuous depression for a few seconds (??)
Date: Fri, 26 Aug 2022 11:06:13 +0200
Lines: 38
Message-ID: <ygasfljs7ay.fsf@akutech.de>
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
<te912m$kc9$1@gioia.aioe.org> <ygawnavs7pb.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net MO1JWBjhGth88FrTaaAxngdPfBWc/0VA3WA4/REFe8ZQyL8Y4=
Cancel-Lock: sha1:LwNZzbMLFprNi4f1nOuQ/bqbkgE= sha1:ExD3+08L8n4YniGx/Vmt0nLAWdA=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)
 by: Ralf Fassel - Fri, 26 Aug 2022 09:06 UTC

* Ralf Fassel <ralfixx@gmx.de>
| * saitology9@gmail.com
| | It is not stuck. You can configure it with a -command option to print
| | something to the console to confirm. As to why it appears that way,
| | since no mouse movement/click was involved, it still has the focus and
| | it shows this by displaying it in the "depressed" state.
>
| Seems like the Button-release-event which reconfigures the 'raised'
| relief gets lost somehow. The button is fully functional, reacts to
| mouse and keyboard, just the relief is 'sunken' instead of 'raised'.

And looking at the code whichs gets called on pressing 'Space', it
becomes clear:

proc ::tk::ButtonInvoke w {
if {[winfo exists $w] && [$w cget -state] ne "disabled"} {
set oldRelief [$w cget -relief]
set oldState [$w cget -state]
$w configure -state active -relief sunken
after 100 [list ::tk::ButtonInvokeEnd $w $oldState $oldRelief]
}
}

proc ::tk::ButtonInvokeEnd {w oldState oldRelief} {
if {[winfo exists $w]} {
$w configure -state $oldState -relief $oldRelief
uplevel #0 [list $w invoke]
}
}

If you keep pressing Space, the next button press arrives while the
button is still in the 'sunken' state (< 100ms), thus it will never get
configured to 'raised' again.

When selling a motocycle, this would be "technically 100%,
optically... not so much" ;-)

R'

Re: button stuck after continuous depression for a few seconds (??)

<caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19973&group=comp.lang.tcl#19973

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a0c:8ecc:0:b0:473:2fa4:df7c with SMTP id y12-20020a0c8ecc000000b004732fa4df7cmr1646908qvb.55.1661557859662;
Fri, 26 Aug 2022 16:50:59 -0700 (PDT)
X-Received: by 2002:a9d:22c7:0:b0:639:c1a4:41df with SMTP id
y65-20020a9d22c7000000b00639c1a441dfmr747144ota.238.1661557859404; Fri, 26
Aug 2022 16:50:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Fri, 26 Aug 2022 16:50:59 -0700 (PDT)
In-Reply-To: <ygasfljs7ay.fsf@akutech.de>
Injection-Info: google-groups.googlegroups.com; posting-host=201.231.246.253; posting-account=DnakAAoAAAA9ZZlBDSXHBE9MWv_A1hHG
NNTP-Posting-Host: 201.231.246.253
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
<te912m$kc9$1@gioia.aioe.org> <ygawnavs7pb.fsf@akutech.de> <ygasfljs7ay.fsf@akutech.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com>
Subject: Re: button stuck after continuous depression for a few seconds (??)
From: xolodho@gmail.com (xol odho)
Injection-Date: Fri, 26 Aug 2022 23:50:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 10
 by: xol odho - Fri, 26 Aug 2022 23:50 UTC

Nice catch. It's a bad interleaving of events then.

Let me see if I get this right...

If a second ButtonInvoke runs before the first ButtonInvokeEnd restablishes the button back to normal/raised, then the oldState/oldRelief variables get overwritten wrongly with active/sunken values, so then ButtonInvokeEnd does not reset them correctly. Perhaps ButtonInvoke should be stopped from touching anything (or running at all) if the button is still depressed. Then these two procs would run in strict pairs without allowing a second ButtonInvoke messing things in between...

Re: button stuck after continuous depression for a few seconds (??)

<nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20032&group=comp.lang.tcl#20032

  copy link   Newsgroups: comp.lang.tcl
From: look@the.footer.invalid (Erik Leunissen)
Subject: Re: button stuck after continuous depression for a few seconds (??)
Newsgroups: comp.lang.tcl
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com> <te912m$kc9$1@gioia.aioe.org> <ygawnavs7pb.fsf@akutech.de> <ygasfljs7ay.fsf@akutech.de> <caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com>
X-Mozilla-News-Host: news://news.xs4all.nl
Date: Sat, 3 Sep 2022 11:03:31 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1
MIME-Version: 1.0
In-Reply-To: <caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!feeder.usenetexpress.com!tr2.eu1.usenetexpress.com!94.232.112.246.MISMATCH!feed.abavia.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 28
Injection-Date: Sat, 03 Sep 2022 11:03:31 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Erik Leunissen - Sat, 3 Sep 2022 09:03 UTC

On 27/08/2022 01:50, xol odho wrote:
> Nice catch. It's a bad interleaving of events then.
>
> Let me see if I get this right...
>
> If a second ButtonInvoke runs before the first ButtonInvokeEnd restablishes the button back to normal/raised, then the oldState/oldRelief variables get overwritten wrongly with active/sunken values, so then ButtonInvokeEnd does not reset them correctly. Perhaps ButtonInvoke should be stopped from touching anything (or running at all) if the button is still depressed. Then these two procs would run in strict pairs without allowing a second ButtonInvoke messing things in between...
>

I agree with your analysis of the misbehaviour, and the design foundation for a fix.

Implementation-wise that would be something like:

proc ::tk::ButtonInvoke w {
if {[winfo exists $w] && ([$w cget -state] ni {disabled active})} {
set oldRelief [$w cget -relief]
set oldState [$w cget -state]
$w configure -state active -relief sunken
after 100 [list ::tk::ButtonInvokeEnd $w $oldState $oldRelief]
}
}

I believe a Tk bug ticket including a fix proposal is appropriate.

Erik.
--
elns@ nl | Merge the left part of these two lines into one,
xs4all. | respecting a character's position in a line.

Re: button stuck after continuous depression for a few seconds (??)

<5300bdcb-1585-4037-bff3-6fc3ee4c78can@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20048&group=comp.lang.tcl#20048

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ad4:5ca7:0:b0:4ac:7fd7:7d78 with SMTP id q7-20020ad45ca7000000b004ac7fd77d78mr64943qvh.51.1662613652553;
Wed, 07 Sep 2022 22:07:32 -0700 (PDT)
X-Received: by 2002:a05:6830:1e85:b0:638:c371:a00d with SMTP id
n5-20020a0568301e8500b00638c371a00dmr2749191otr.177.1662613652274; Wed, 07
Sep 2022 22:07:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 7 Sep 2022 22:07:32 -0700 (PDT)
In-Reply-To: <nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555>
Injection-Info: google-groups.googlegroups.com; posting-host=201.231.246.253; posting-account=DnakAAoAAAA9ZZlBDSXHBE9MWv_A1hHG
NNTP-Posting-Host: 201.231.246.253
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
<te912m$kc9$1@gioia.aioe.org> <ygawnavs7pb.fsf@akutech.de>
<ygasfljs7ay.fsf@akutech.de> <caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com>
<nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5300bdcb-1585-4037-bff3-6fc3ee4c78can@googlegroups.com>
Subject: Re: button stuck after continuous depression for a few seconds (??)
From: xolodho@gmail.com (xol odho)
Injection-Date: Thu, 08 Sep 2022 05:07:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3605
 by: xol odho - Thu, 8 Sep 2022 05:07 UTC

Yes, something along those lines might do it: you check whether the button
is busy transitioning and stop right there, not more race condition.

But perhaps this could be fixed at a lower (and more general) level,
instead of hardcoding it using specific widget states or tracking state
with external variables. More precisely, the button binding script could
just ignore repeated keypresses, so tk::ButtonInvoke doesn't even get to
run until the next physical keypress. This way you don't need to manually
track state changes or anything because the asynchronous race would become
impossible.

For comparison, when you hold a mouseclick, it is impossible to get a
"repeated" click while the mousebutton is depressed, so the bad
interleaving is impossible for mouseclicks on Tk buttons, and so that
obviates any need for extra ad-hoc state tracking.

So, is it possible to (easily, reliably) detect an auto-repeated keypress
in Tk? Perhaps `bind` could provide a percent-substitution with a boolean
value? Or perhaps some trick using <Double-Keypress-*> bindings ? I'm
really envying SDL's SDL_KeyboardEvent and Winapi's WM_KEYDOWN message,
both carry an explicit boolean indication for repeated keypresses.

Also, I notice the mouse-click logic and the spacebar-down logic use
different code paths in button.tcl, perhaps they could share behavior?
i.e., holding down click vs holding down spacebar, does the difference
matter? In win32, a native button get depressed while click/space is down
(repeats ignored) but the command fires only at last when click/space is
released (both cases produce a WM_COMMAND message). I've been wondering
about this...

Last but not least, the <KeyRelease> event does not work properly on my
X11 desktops with autorepeat on (Tk 8.6.12 on i3wm, xfce, etc), for
instance with this code :

bind . <KeyPress> {puts "%# KeyPress %K"}
bind . <KeyRelease> {puts "%# KeyRelease %K"}

On X11 while I hold down some key, that prints a stream of alternated
KeyPress and KeyRelease lines, but the proper behaviour should be a unique
<KeyRelease> after each <KeyPress> repeated sequence, for each physical
key down/up pair. There was a similar bug reported for MacOSX some years
ago. It works correctly on Win32.

Re: button stuck after continuous depression for a few seconds (??)

<76f855d5-9107-4719-b90e-f5ae76d433c2n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20049&group=comp.lang.tcl#20049

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:2b0c:b0:499:c34:5f99 with SMTP id jx12-20020a0562142b0c00b004990c345f99mr6101095qvb.40.1662616732598;
Wed, 07 Sep 2022 22:58:52 -0700 (PDT)
X-Received: by 2002:a05:6870:e2d0:b0:127:9969:c9ab with SMTP id
w16-20020a056870e2d000b001279969c9abmr1036209oad.56.1662616732387; Wed, 07
Sep 2022 22:58:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 7 Sep 2022 22:58:52 -0700 (PDT)
In-Reply-To: <nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555>
Injection-Info: google-groups.googlegroups.com; posting-host=201.231.246.253; posting-account=DnakAAoAAAA9ZZlBDSXHBE9MWv_A1hHG
NNTP-Posting-Host: 201.231.246.253
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com>
<te912m$kc9$1@gioia.aioe.org> <ygawnavs7pb.fsf@akutech.de>
<ygasfljs7ay.fsf@akutech.de> <caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com>
<nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <76f855d5-9107-4719-b90e-f5ae76d433c2n@googlegroups.com>
Subject: Re: button stuck after continuous depression for a few seconds (??)
From: xolodho@gmail.com (xol odho)
Injection-Date: Thu, 08 Sep 2022 05:58:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3533
 by: xol odho - Thu, 8 Sep 2022 05:58 UTC

Yes, something along those lines might do it: you check whether the button
is busy transitioning and stop right there, not more race condition.

But perhaps this could be fixed at a lower (and more general) level,
instead of hardcoding it using specific widget states or tracking state
with external variables. More precisely, the button binding script could
just ignore repeated keypresses, so tk::ButtonInvoke doesn't even get to
run until the next physical keypress. This way you don't need to manually
track state changes.

For comparison, with the mouse, it is impossible to get a "repeated" click
while the mousebutton is depressed, so the bad interleaving is impossible
for mouseclicks on Tk buttons, and so that obviates any need for extra
ad-hoc state tracking.

So, is it possible to (easily, reliably) detect an auto-repeated keypress
in Tk? Perhaps `bind` could provide a percent-substitution with a boolean
value? Or perhaps some trick using <Double-Keypress-*> bindings ? I'm
really envying SDL's SDL_KeyboardEvent and Winapi's WM_KEYDOWN message,
both carry an explicit boolean indication for repeated keypresses.

Also, I notice the mouse-click logic and the spacebar-down logic use
different code paths in button.tcl, perhaps they could share behavior?
i.e., holding down click vs holding down spacebar, does the difference
matter? In win32, a native button gets depressed while click/space is down
(repeats ignored) but the command fires only at last when click/space is
released (both cases produce a WM_COMMAND message). I've been wondering
about this...

Last but not least, the <KeyRelease> event does not work properly on my
X11 desktops with autorepeat on (Tk 8.6.12 on i3wm, xfce, etc), for
instance with this code :

bind . <KeyPress> {puts "%# KeyPress %K"}
bind . <KeyRelease> {puts "%# KeyRelease %K"}

On X11 while I hold down some key, that prints a stream of alternated
KeyPress and KeyRelease lines, but the proper behaviour should be a unique
<KeyRelease> after each <KeyPress> repeated sequence, for each physical
key down/up pair. There was a similar bug reported for MacOSX some years
ago. It works correctly on Win32.

Re: button stuck after continuous depression for a few seconds (??)

<nnd$5009f527$4c95d664@4e14f4e0721681c9>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20050&group=comp.lang.tcl#20050

  copy link   Newsgroups: comp.lang.tcl
From: look@the.footer.invalid (Erik Leunissen)
Subject: Re: button stuck after continuous depression for a few seconds (??)
Newsgroups: comp.lang.tcl
References: <5b387371-6705-4235-becf-779035621f04n@googlegroups.com> <te912m$kc9$1@gioia.aioe.org> <ygawnavs7pb.fsf@akutech.de> <ygasfljs7ay.fsf@akutech.de> <caaa9392-6b03-4de0-b36c-bbcb363b3797n@googlegroups.com> <nnd$2e9b16ed$2bf77bb9@bec5c87c2e11c555> <76f855d5-9107-4719-b90e-f5ae76d433c2n@googlegroups.com>
X-Mozilla-News-Host: news://news.xs4all.nl
Date: Sun, 11 Sep 2022 10:01:44 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1
MIME-Version: 1.0
In-Reply-To: <76f855d5-9107-4719-b90e-f5ae76d433c2n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$5009f527$4c95d664@4e14f4e0721681c9>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!94.232.112.245.MISMATCH!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 63
Injection-Date: Sun, 11 Sep 2022 10:01:44 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Erik Leunissen - Sun, 11 Sep 2022 08:01 UTC

On 08/09/2022 07:58, xol odho wrote:

> But perhaps this could be fixed at a lower (and more general) level,

I think hat your suggestions below are worth pursuing in the context of the misbehaviour that you
reported previously. I'd be sorry if they weren't.

I believe, now even more, that a Tk bug ticket including your suggestions (or a fix proposal) is
appropriate. Personally, I'm not experienced enough to comment in detail on your suggestions, but Tk
maintainers may be).

By the way:

https://core.tcl-lang.org/tk/ticket

Sincerely,
Erik Leunissen
--

> instead of hardcoding it using specific widget states or tracking state
> with external variables. More precisely, the button binding script could
> just ignore repeated keypresses, so tk::ButtonInvoke doesn't even get to
> run until the next physical keypress. This way you don't need to manually
> track state changes.
>
> For comparison, with the mouse, it is impossible to get a "repeated" click
> while the mousebutton is depressed, so the bad interleaving is impossible
> for mouseclicks on Tk buttons, and so that obviates any need for extra
> ad-hoc state tracking.
>
> So, is it possible to (easily, reliably) detect an auto-repeated keypress
> in Tk? Perhaps `bind` could provide a percent-substitution with a boolean
> value? Or perhaps some trick using <Double-Keypress-*> bindings ? I'm
> really envying SDL's SDL_KeyboardEvent and Winapi's WM_KEYDOWN message,
> both carry an explicit boolean indication for repeated keypresses.
>
> Also, I notice the mouse-click logic and the spacebar-down logic use
> different code paths in button.tcl, perhaps they could share behavior?
> i.e., holding down click vs holding down spacebar, does the difference
> matter? In win32, a native button gets depressed while click/space is down
> (repeats ignored) but the command fires only at last when click/space is
> released (both cases produce a WM_COMMAND message). I've been wondering
> about this...
>
> Last but not least, the <KeyRelease> event does not work properly on my
> X11 desktops with autorepeat on (Tk 8.6.12 on i3wm, xfce, etc), for
> instance with this code :
>
> bind . <KeyPress> {puts "%# KeyPress %K"}
> bind . <KeyRelease> {puts "%# KeyRelease %K"}
>
> On X11 while I hold down some key, that prints a stream of alternated
> KeyPress and KeyRelease lines, but the proper behaviour should be a unique
> <KeyRelease> after each <KeyPress> repeated sequence, for each physical
> key down/up pair. There was a similar bug reported for MacOSX some years
> ago. It works correctly on Win32.
>

--
elns@ nl | Merge the left part of these two lines into one,
xs4all. | respecting a character's position in a line.


devel / comp.lang.tcl / Re: button stuck after continuous depression for a few seconds (??)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor