Home > Archive > Tcl > May 2007 > Painful disabling of autorepeat ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Painful disabling of autorepeat ?
|
|
| Alexandre Ferrieux 2007-05-24, 7:12 pm |
| Hi,
I'm wondering about the current idiom for disabling keyboard
autorepeat in Tk.
>From my tests it seems that autorepeated keys[*] always generate
Release-Press sequences with the same timesatmp (%t). So it seems the
only method implies setting up an very short [after] on Release,
cancel it on Press, and consider a true Release when it gets to
completion.
Questions:
- is it the best bethod ?
- what is a safe value for the timer (guaranteeing that it won't
complete *between* the notification of the two events) ? (a large
value delays the true Release notification).
-Alex
| |
| Uwe Klein 2007-05-25, 4:22 am |
| Alexandre Ferrieux wrote:
> On May 24, 5:10 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
> wrote:
>
>
>
> Thanks, but (1) it is X-specific and (2)
any other usable platform?
it is system-wide (I mean
> display-wide).
bind to <enter> and <leave>
> In fact I'm not looking for an external workaround, I just want to
> know if there's a better Tcl-only solution.
if it uses [package require] it can't really be external, can it?
> Otherwise, I think there's room for a TIP.
>
> -Alex
>
G!
uwe
| |
| Donal K. Fellows 2007-05-25, 8:08 am |
| Alexandre Ferrieux wrote:
> I'm wondering about the current idiom for disabling keyboard
> autorepeat in Tk.
> From my tests it seems that autorepeated keys[*] always generate
> Release-Press sequences with the same timesatmp (%t).
FWIW, on Windows you don't get a <KeyRelease> between autorepeated
<KeyPress> events. (Or at least I didn't get that when I tested!)
> So it seems the
> only method implies setting up an very short [after] on Release,
> cancel it on Press, and consider a true Release when it gets to
> completion.
Since the release is guaranteed to precede the press, what you could do
is just save the timestamp of the last release. Since that's just a
simple variable, it'll be easy to implement.
Another thing to check is whether the serial numbers are the same or
not; if they're the same, then that gives you an even better way of
detecting that it's not a real release/re-press. But I can't check that
on Windows for you; this is an area where it seems that the platforms
aren't precisely equivalent.
Donal.
| |
| Ralf Fassel 2007-05-25, 8:08 am |
| * Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
| So, basically, the answer is: "the recommended idiom is the above",
| right ?
Yes.
R'
| |
| Alexandre Ferrieux 2007-05-25, 7:09 pm |
| On May 25, 11:28 am, "Donal K. Fellows"
<donal.k.fell...@manchester.ac.uk> wrote:
> Alexandre Ferrieux wrote:
>
> FWIW, on Windows you don't get a <KeyRelease> between autorepeated
> <KeyPress> events. (Or at least I didn't get that when I tested!)
Even worse: not even consistent between unix and windows...
Why this ?
>
> Since the release is guaranteed to precede the press, what you could do
> is just save the timestamp of the last release. Since that's just a
> simple variable, it'll be easy to implement.
Yes but in my case (and in the case of many games, see the Asteroids
on the wiki) I also want a callback to be called on the Release event.
So I need the [after] in order to do something after the last Release.
> Another thing to check is whether the serial numbers are the same or
> not; if they're the same, then that gives you an even better way of
> detecting that it's not a real release/re-press. But I can't check that
> on Windows for you; this is an area where it seems that the platforms
> aren't precisely equivalent.
On Windows you've just said there was no fake Release, so here it
suffices to keep a flag recording the fact that we are in the Pressed
state...
So, the method with the equality of timestamps *and* the [after] works
in all cases and OSes.
But I'm far from saying I'm *happy* with such a kludge :^{
Ain't it TIPpable ?
-Alex
| |
| Alexandre Ferrieux 2007-05-26, 8:07 am |
| On May 26, 12:45 am, "Donal K. Fellows"
<donal.k.fell...@manchester.ac.uk> wrote:
> Alexandre Ferrieux wrote:
>
> Since it is arguably a fault in the way Xservers handle key events, no.
> TIPs don't apply to Xservers (unless they're written in Tcl, of course.)
What I mean is: it is frustrating to have to deploy such a complicated
script-level workaround. It would be both more efficient and easier
for Tcl developer to do it in C...
-Alex
| |
| Ralf Fassel 2007-05-26, 8:07 am |
| * Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
| What I mean is: it is frustrating to have to deploy such a
| complicated script-level workaround. It would be both more efficient
| and easier for Tcl developer to do it in C...
Being curious: how would it be easier in C?
R'
| |
| Donal K. Fellows 2007-05-26, 8:07 am |
| Alexandre Ferrieux wrote:
> What I mean is: it is frustrating to have to deploy such a complicated
> script-level workaround. It would be both more efficient and easier
> for Tcl developer to do it in C...
It would be more likely to happen if you were to suggest with a patch
instead of a vague complaint... ;-)
Donal.
| |
| Alexandre Ferrieux 2007-05-26, 7:11 pm |
| On May 26, 2:22 pm, Ralf Fassel <ralf...@gmx.de> wrote:
> * Alexandre Ferrieux <alexandre.ferri...@gmail.com>
> | What I mean is: it is frustrating to have to deploy such a
> | complicated script-level workaround. It would be both more efficient
> | and easier for Tcl developer to do it in C...
>
> Being curious: how would it be easier in C?
Read again: easier for the Tcl developer.
That means: we write it in C, and immediately Tk becomes more
consistent across platforms. The common behavior becomes what's
already happening on windows: several Press and just one Release. So
the interested Tcl scripter just has to keep a flag to tell fake Press
from true ones.
-Alex
|
|
|
|
|