added wxTextCtrl::EmulateKeyPress

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-04-07 22:29:04 +00:00
parent 15bee36fdf
commit 94af7d45ef
7 changed files with 121 additions and 67 deletions

View File

@@ -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
// ----------------------------------------------------------------------------