]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
Further fixes to references
[wxWidgets.git] / src / msw / textctrl.cpp
index 43ca7b27ef2755eede5f3e286b6e707dd3d33d46..cee29ac19eceb291fcea5fe7516f5ba6970a4640 100644 (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
 // ----------------------------------------------------------------------------