Re: keys/chars events handling

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: keys/chars events handling

Mart Raudsepp
On Thu, 2005-11-10 at 13:02 +0100, Vadim Zeitlin wrote:

> On Tue, 08 Nov 2005 09:04:11 +0100 jmf <[hidden email]> wrote:
>
> j> IsKey(char key, int modifiers)
> j>
> j> is a good idea.
>
>  We may still add it later but for now I've just added
> wxKeyEvent::GetModifiers() which returns a bit mask of wxMOD_XXX (where XXX
> = Shift, Ctrl, Alt, Meta). This allows to write correct code easily, e.g.
>
> if ( event.GetModifiers() == wxMOD_CONTROL )
>
> instead of (wrong)
>
> if ( event.ControlDown() )
>
> or (correct but long)

I'm going through my unfiltered INBOX messages, and found that I didn't
follow this thread earlier.
Hate to bring such an old thread alive, but:

How precisely is such a method going to help not write wrong code?
Especially if the bit mask contains Shift, Ctrl, Alt and Meta, but not
AltGr.
Let me list the problems that I see with this:

a) AltGr != ctrl+alt on some platform, most notably any X11 one (with
estonian layout, at least). In fact, currently I don't see any of these
modifiers being on in the text sample when I hold down AltGr.

b) Meta == Numlock often in X11. If the app developer does
event.GetModifiers() == wxMOD_CONTROL then it won't match if the numlock
is on, and it pretty often is. If I have numlock on and press a key,
then the meta modifier is shown as active in the text sample tests.
GTK+ resolved this with a default modifier mask - See
http://developer.gnome.org/doc/API/2.0/gtk/checklist-modifiers.html

With Regards,
  Mart Raudsepp



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re[2]: keys/chars events handling

Vadim Zeitlin-3
On Tue, 07 Mar 2006 10:09:19 +0200 Mart Raudsepp <[hidden email]> wrote:

MR> On Thu, 2005-11-10 at 13:02 +0100, Vadim Zeitlin wrote:
MR> > On Tue, 08 Nov 2005 09:04:11 +0100 jmf <[hidden email]> wrote:
MR> >
MR> > j> IsKey(char key, int modifiers)
MR> > j>
MR> > j> is a good idea.
MR> >
MR> >  We may still add it later but for now I've just added
MR> > wxKeyEvent::GetModifiers() which returns a bit mask of wxMOD_XXX (where XXX
MR> > = Shift, Ctrl, Alt, Meta). This allows to write correct code easily, e.g.
MR> >
MR> > if ( event.GetModifiers() == wxMOD_CONTROL )
MR> >
MR> > instead of (wrong)
MR> >
MR> > if ( event.ControlDown() )
MR> >
MR> > or (correct but long)
...
MR> How precisely is such a method going to help not write wrong code?

 As indicated above: the first "if" only works for real Ctrl-Foo key
presses and not for Ctrl-Alt-Foo.

MR> Especially if the bit mask contains Shift, Ctrl, Alt and Meta, but not
MR> AltGr.

 If it contains anything but Ctrl (and maybe Shift) you normally don't want
to treat it as Ctrl-anything. Current ControlDown() is very misleading IMO.

MR> Let me list the problems that I see with this:
MR>
MR> a) AltGr != ctrl+alt on some platform, most notably any X11 one (with
MR> estonian layout, at least). In fact, currently I don't see any of these
MR> modifiers being on in the text sample when I hold down AltGr.

 I think we should translate AltGr to Ctrl+Alt on all platforms.

MR> b) Meta == Numlock often in X11. If the app developer does
MR> event.GetModifiers() == wxMOD_CONTROL then it won't match if the numlock
MR> is on, and it pretty often is.

 Good point. So the right thing to do is probably to ignore this modifier
(or, if we can, ignore the modifier Numlock is mapped to).

MR> If I have numlock on and press a key, then the meta modifier is shown
MR> as active in the text sample tests. GTK+ resolved this with a default
MR> modifier mask - See
MR> http://developer.gnome.org/doc/API/2.0/gtk/checklist-modifiers.html

 Well, GetModifiers() could/should do the same. Except, luckily, CapsLock
is not counted as modified by wx. Neither should Numlock ideally. There is
just no way to map X11 modifiers craziness^H^H^H^H^H^H^H^H^Hflexibility to
other platforms.

 Regards,
VZ


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]