[wx-discuss] keys/chars events handling
Vadim Zeitlin
vadim at wxwindows.org
Tue Mar 7 03:10:41 PST 2006
On Tue, 07 Mar 2006 10:09:19 +0200 Mart Raudsepp <leio at dustbite.net> 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 <jfauth at bluewin.ch> 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: wx-discuss-unsubscribe at lists.wxwidgets.org
For additional commands, e-mail: wx-discuss-help at lists.wxwidgets.org
More information about the wx-discuss
mailing list