Discussion:
ESC key not received as wxEVT_CHAR in wxTextCtrl (OSX-Cocoa)
Alexandru Ciprian Branescu
2014-08-20 12:41:23 UTC
Permalink
Run the keyboard sample on OS X, go to File menu and choose Use text ctrl
(or text entry).
Type Escape and notice there is no char event received - only keydown,
keyup and charhook events (the same happens for arrow keys,
PgUp/Down/Begin/End,etc.).

Is this as intended for Mac or a known bug? It doesn't happen on wxGTK or
wxMSW.
If it is a bug, I can probably work on it although I'm only novice on Mac.
If not, it should probably be documented? Because the behaviour differs
from other platforms.

Thanks,
Alexandru Branescu.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Alexandru Ciprian Branescu
2014-08-20 12:47:04 UTC
Permalink
This post might be inappropriate. Click to display it.
Vadim Zeitlin
2014-08-20 17:30:59 UTC
Permalink
On Wed, 20 Aug 2014 05:41:23 -0700 (PDT) Alexandru Ciprian Branescu wrote:

ACB> Run the keyboard sample on OS X, go to File menu and choose Use text ctrl
ACB> (or text entry).
ACB> Type Escape and notice there is no char event received - only keydown,
ACB> keyup and charhook events (the same happens for arrow keys,
ACB> PgUp/Down/Begin/End,etc.).
ACB>
ACB> Is this as intended for Mac or a known bug? It doesn't happen on wxGTK or
ACB> wxMSW.

Actually for me there are no wxEVT_KEY_DOWN nor wxEVT_CHAR events for Esc
neither under MSW because it's used as an accelerators and these events are
consumed when translating it to the corresponding menu action,
independently of which kind of window is used for entry.

Handling of accelerators in wxGTK is still broken however...

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Alexandru Ciprian Branescu
2014-08-20 19:10:27 UTC
Permalink
Indeed I forgot to mention you have to disable Connect(TestAccelEsc, ... )
in code, then recompile.

I've just retested, after removing the accelerator intercept and char hook,
and it seems with head of trunk things are different:

Custom Control: Esc is received as KEY_UP; arrow keys as KEY_UP/DOWN/CHAR
Text Entry: Esc is received as KEY_UP; arrow keys as
KEY_UP/DOWN/CHAR
Text Ctrl: Esc is received as KEY_UP; arrow keys as
KEY_UP/DOWN/CHAR

Mac (Cocoa):

Custom Control: Esc is received as KEY_UP; arrow keys as
KEY_UP/DOWN/CHAR
Text Entry: Esc is received KEY_DOWN/UP; arrow keys as KEY_UP/DOWN
Text Ctrl: Esc is received as KEY_UP; arrow keys as
KEY_UP/DOWN

Gtk:

Custom Control: Esc is received as KEY_UP/DOWN/CHAR; arrow keys as
KEY_UP/DOWN/CHAR
Text Entry: Esc is received as KEY_UP/DOWN/CHAR; arrow keys as
KEY_UP/DOWN/CHAR
Text Ctrl: Esc is received as KEY_UP/DOWN/CHAR; arrow keys as
KEY_UP/DOWN/CHAR

So things are not exactly consistent. What I was wondering about is what I
should expect.
The documentation doesn't mention how to handle these keys (as EVT_KEY_DOWN
or EVT_CHAR), only talks about modifiers, etc.
If there are bugs, I may be able to work on fixing them, but I need to know
the intended behaviour.

Best regards,
Alexandru Branescu.

On Wednesday, August 20, 2014 3:41:23 PM UTC+3, Alexandru Ciprian Branescu
Post by Alexandru Ciprian Branescu
Run the keyboard sample on OS X, go to File menu and choose Use text ctrl
(or text entry).
Type Escape and notice there is no char event received - only keydown,
keyup and charhook events (the same happens for arrow keys,
PgUp/Down/Begin/End,etc.).
Is this as intended for Mac or a known bug? It doesn't happen on wxGTK or
wxMSW.
If it is a bug, I can probably work on it although I'm only novice on Mac.
If not, it should probably be documented? Because the behaviour differs
from other platforms.
Thanks,
Alexandru Branescu.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-08-20 20:47:10 UTC
Permalink
On Wed, 20 Aug 2014 12:10:27 -0700 (PDT) Alexandru Ciprian Branescu wrote:

ACB> I've just retested, after removing the accelerator intercept and char hook,
ACB> and it seems with head of trunk things are different:
ACB>

[MSW I assume]
ACB> Custom Control: Esc is received as KEY_UP; arrow keys as KEY_UP/DOWN/CHAR
ACB> Text Entry: Esc is received as KEY_UP; arrow keys as KEY_UP/DOWN/CHAR
ACB> Text Ctrl: Esc is received as KEY_UP; arrow keys as KEY_UP/DOWN/CHAR
ACB>
ACB> Mac (Cocoa):
ACB>
ACB> Custom Control: Esc is received as KEY_UP; arrow keys as KEY_UP/DOWN/CHAR
ACB> Text Entry: Esc is received KEY_DOWN/UP; arrow keys as KEY_UP/DOWN
ACB> Text Ctrl: Esc is received as KEY_UP; arrow keys as KEY_UP/DOWN
ACB>
ACB> Gtk:
ACB>
ACB> Custom Control: Esc is received as KEY_UP/DOWN/CHAR; arrow keys as KEY_UP/DOWN/CHAR
ACB> Text Entry: Esc is received as KEY_UP/DOWN/CHAR; arrow keys as KEY_UP/DOWN/CHAR
ACB> Text Ctrl: Esc is received as KEY_UP/DOWN/CHAR; arrow keys as KEY_UP/DOWN/CHAR
ACB>
ACB> So things are not exactly consistent.

Yes, this doesn't look so good. I don't know why you don't get
KEY_DOWN/CHAR for Escape under MSW and OSX, could it be that the presence
of "Esc" as accelerator in the menu string breaks something, even if the
event from the corresponding menu item is not handled?

The ideal behaviour would, of course, be to send all events for all keys
under all platforms (assuming the events are not handled, i.e. any handlers
call wxEvent::Skip()).

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...