]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
Further fixes to references
[wxWidgets.git] / src / msw / textctrl.cpp
index e9bbcc1ad55477c6292036242fb3d027aa7c6ae7..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
 // ----------------------------------------------------------------------------
@@ -1489,7 +1508,6 @@ bool wxTextCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *re
                 ::SetCursor(GetHcursorOf(wxCursor(wxCURSOR_HAND)));
                 *result = TRUE;
                 break;
-
             case WM_MOUSEMOVE:
             case WM_LBUTTONDOWN:
             case WM_LBUTTONUP: