Simulating keys such as WXK_END resulted in WXK_NUMPAD_END event being
generated instead of the expected WXK_END one.
Fix this by returning from wxCharCodeWXToMSW() whether the key code is a
normal or extended one and use this to set KEYEVENTF_EXTENDEDKEY in
wxUIActionSimulator::DoKey().
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65518
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// global functions
// ---------------------------------------------------------------------------
-// kbd code translation
+// key codes translation between wx and MSW
WXDLLIMPEXP_CORE int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam = 0);
-WXDLLIMPEXP_CORE WXWORD wxCharCodeWXToMSW(int id);
+WXDLLIMPEXP_CORE WXWORD wxCharCodeWXToMSW(int id, bool *isExtended = NULL);
// window creation helper class: before creating a new HWND, instantiate an
// object of this class on stack - this allows to process the messages sent to
bool
wxUIActionSimulator::DoKey(int keycode, int WXUNUSED(modifiers), bool isDown)
{
- DWORD vkkeycode = wxCharCodeWXToMSW(keycode);
- keybd_event(vkkeycode, 0, isDown ? 0 : KEYEVENTF_KEYUP, 0);
+ bool isExtended;
+ DWORD vkkeycode = wxCharCodeWXToMSW(keycode, &isExtended);
+
+ DWORD flags = 0;
+ if ( isExtended )
+ flags |= KEYEVENTF_EXTENDEDKEY;
+ if ( !isDown )
+ flags |= KEYEVENTF_KEYUP;
+
+ keybd_event(vkkeycode, 0, flags, 0);
return true;
}
return wxk;
}
-WXWORD wxCharCodeWXToMSW(int wxk)
+WXWORD wxCharCodeWXToMSW(int wxk, bool *isExtended)
{
// check the table first
for ( size_t n = 0; n < WXSIZEOF(gs_specialKeys); n++ )
{
if ( gs_specialKeys[n].wxk == wxk )
+ {
+ // All extended keys (i.e. non-numpad versions of the keys that
+ // exist both in the numpad and outside of it) are dealt with
+ // below.
+ if ( isExtended )
+ *isExtended = false;
+
return gs_specialKeys[n].vk;
+ }
}
// and then check for special keys not included in the table
+ bool extended = false;
WXWORD vk;
switch ( wxk )
{
case WXK_PAGEUP:
+ extended = true;
case WXK_NUMPAD_PAGEUP:
vk = VK_PRIOR;
break;
case WXK_PAGEDOWN:
+ extended = true;
case WXK_NUMPAD_PAGEDOWN:
vk = VK_NEXT;
break;
case WXK_END:
+ extended = true;
case WXK_NUMPAD_END:
vk = VK_END;
break;
case WXK_HOME:
+ extended = true;
case WXK_NUMPAD_HOME:
vk = VK_HOME;
break;
case WXK_LEFT:
+ extended = true;
case WXK_NUMPAD_LEFT:
vk = VK_LEFT;
break;
case WXK_UP:
+ extended = true;
case WXK_NUMPAD_UP:
vk = VK_UP;
break;
case WXK_RIGHT:
+ extended = true;
case WXK_NUMPAD_RIGHT:
vk = VK_RIGHT;
break;
case WXK_DOWN:
+ extended = true;
case WXK_NUMPAD_DOWN:
vk = VK_DOWN;
break;
case WXK_INSERT:
+ extended = true;
case WXK_NUMPAD_INSERT:
vk = VK_INSERT;
break;
case WXK_DELETE:
+ extended = true;
case WXK_NUMPAD_DELETE:
vk = VK_DELETE;
break;
}
}
+ if ( isExtended )
+ *isExtended = extended;
+
return vk;
}