Add WXK_NUMPAD_CENTER to refer to numpad "5" in portable code

This key produces events with different key codes in wxMSW (WXK_CLEAR)
and the other ports (WXK_NUMPAD_BEGIN), so add a new constant to allow
to refer to it under the same name everywhere.

Also generate a key event for it in wxOSX where it previously wasn't
generated at all.

Closes #23478.

Closes #23491.
This commit is contained in:
Ivan Sorokin 2023-04-25 03:01:56 +03:00 committed by Vadim Zeitlin
parent 4df2c878f4
commit 8a01942f1a
5 changed files with 29 additions and 8 deletions

View file

@ -2363,7 +2363,15 @@ enum wxKeyCode
// These constants are the same as the corresponding GTK keys, so give them
// the same value, but they are also generated by wxMSW.
WXK_LAUNCH_APP1 = WXK_LAUNCH_A,
WXK_LAUNCH_APP2 = WXK_LAUNCH_B
WXK_LAUNCH_APP2 = WXK_LAUNCH_B,
// This one provides a portable way to refer to the key event generated by
// the "5" key on the numpad when Num Lock is off.
#ifdef __WXMSW__
WXK_NUMPAD_CENTER = WXK_CLEAR
#else
WXK_NUMPAD_CENTER = WXK_NUMPAD_BEGIN
#endif
};
/* This enum contains bit mask constants used in wxKeyEvent */

View file

@ -924,6 +924,7 @@ enum wxKeyCode
WXK_RBUTTON,
WXK_CANCEL,
WXK_MBUTTON,
/// See WXK_NUMPAD_CENTER.
WXK_CLEAR,
WXK_SHIFT,
WXK_ALT,
@ -1015,6 +1016,7 @@ enum wxKeyCode
WXK_NUMPAD_PAGEUP,
WXK_NUMPAD_PAGEDOWN,
WXK_NUMPAD_END,
/// See WXK_NUMPAD_CENTER.
WXK_NUMPAD_BEGIN,
WXK_NUMPAD_INSERT,
WXK_NUMPAD_DELETE,
@ -1107,7 +1109,19 @@ enum wxKeyCode
WXK_LAUNCH_C, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_D, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_E, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_F ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_F, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
/**
Key code corresponding to the event produced by the "5" key on the
numeric pad when Num Lock is off.
This constant has the same value as WXK_CLEAR under wxMSW and
WXK_NUMPAD_BEGIN in the other ports but using it is preferable in
portable code.
@since 3.3.0
*/
WXK_NUMPAD_CENTER
};
/**

View file

@ -386,7 +386,7 @@ const char* GetVirtualKeyCodeName(int keycode)
WXK_(RBUTTON)
WXK_(CANCEL)
WXK_(MBUTTON)
WXK_(CLEAR)
WXK_(NUMPAD_CENTER)
WXK_(SHIFT)
WXK_(ALT)
WXK_(CONTROL)
@ -464,7 +464,6 @@ const char* GetVirtualKeyCodeName(int keycode)
WXK_(NUMPAD_PAGEUP)
WXK_(NUMPAD_PAGEDOWN)
WXK_(NUMPAD_END)
WXK_(NUMPAD_BEGIN)
WXK_(NUMPAD_INSERT)
WXK_(NUMPAD_DELETE)
WXK_(NUMPAD_EQUAL)

View file

@ -876,7 +876,7 @@ static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar)
break;
case GDK_KEY_KP_Begin:
key_code = isChar ? WXK_HOME : WXK_NUMPAD_BEGIN;
key_code = WXK_NUMPAD_BEGIN;
break;
case GDK_KEY_KP_Insert:

View file

@ -311,9 +311,9 @@ long wxOSXTranslateCocoaKey( NSEvent* event, int eventType )
case NSHomeFunctionKey :
retval = WXK_HOME;
break;
// case NSBeginFunctionKey :
// retval = WXK_BEGIN;
// break;
case NSBeginFunctionKey :
retval = WXK_NUMPAD_BEGIN;
break;
case NSEndFunctionKey :
retval = WXK_END;
break;