If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Is it possible to get a real character in the wxEVT_CHAR_HOOK event handler?
e.g. I want to handle '+', which is shift + '=' key combination, so in the event handler I get '=' key code. Is there some portable way to "calculate" the real character considering the modifiers (which would be '+' in this case)?
Like Qt's QKeyEvent::text():
Returns the Unicode text that this key generated.
Return values when modifier keys such as Shift, Control, Alt, and Meta are pressed differ among platforms and could return an empty string.
Yes, I need wxEVT_CHAR_HOOK (for some reasons). In other cases, I'd need at least EVT_KEY_DOWN - because I need to handle Ctrl- +/- (So it is Ctrl-Shift-= for + on US layout) for zooming in/out and it needs to be done continuously while the keys are pressed - I believe this can NOT be done with wxEVT_CHAR, right?
I'd need at least EVT_KEY_DOWN - because I need to handle Ctrl- +/- (So it is Ctrl-Shift-= for + on US layout) for zooming in/out and it needs to be done continuously while the keys are pressed - I believe this can NOT be done with wxEVT_CHAR, right?
Hi,
There is also EVT_KEY_DOWN event, which I think comes right after EVT_CHAR_HOOK.
EVT_CHAR_HOOK event is unique in the sense that it comes before any actual keyboard event for extra processing. It is mostly used for ESC key processing.
EVT_KEY_DOWN can be used I think in your case. It is much simpler and more portable.
SHORT plusKeyScan = VkKeyScan('+');
BYTE plusKeyCode = LOBYTE(plusKeyScan); // == event.GetRawKeyCode()
BYTE plusModifier = HIBYTE(plusKeyScan); // compare this to modifiers received from wxWidgets