X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e777924b358ae352f30881249f681ebb7a3ce089..81c9effa8462662263c3b4eac2cfae1ef5caae2c:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 43ca7b27ef..cee29ac19e 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -692,6 +692,25 @@ void wxTextCtrl::Clear() ::SetWindowText(GetHwnd(), wxT("")); } +#ifdef __WIN32__ + +bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& event) +{ + SetFocus(); + + size_t lenOld = GetValue().length(); + + wxUint32 code = event.GetRawKeyCode(); + ::keybd_event(code, 0, 0 /* key press */, NULL); + ::keybd_event(code, 0, KEYEVENTF_KEYUP, NULL); + + // assume that any alphanumeric key changes the total number of characters + // in the control - this should work in 99% of cases + return GetValue().length() != lenOld; +} + +#endif // __WIN32__ + // ---------------------------------------------------------------------------- // Clipboard operations // ----------------------------------------------------------------------------