]> git.saurik.com Git - wxWidgets.git/commitdiff
Added private wxEVT_AFTER_CHAR event for wxMSW implementation needs.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 16 Apr 2011 17:27:21 +0000 (17:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 16 Apr 2011 17:27:21 +0000 (17:27 +0000)
This event is sent by wxMSW after the default handling of WM_CHAR has taken
place. It can be used to define an event handler triggered by key presses and
having access to the new value of the control, updated to take the last key
press into account.

This event will be used by auto-completion implementation for wxMSW only for
now.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67512 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/event.h
include/wx/msw/window.h
src/common/event.cpp
src/msw/window.cpp

index dae8470ac9ce7b574990c73bddeaa2405510abfd..01b681c9a12adb4e67086675e6c3bfe6172275fb 100644 (file)
@@ -713,6 +713,10 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_KEY_UP, wxKeyEvent);
 #if wxUSE_HOTKEY
 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_HOTKEY, wxKeyEvent);
 #endif
+// This is a private event used by wxMSW code only and subject to change or
+// disappear in the future. Don't use.
+wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AFTER_CHAR, wxKeyEvent);
+
     // Set cursor event
 wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SET_CURSOR, wxSetCursorEvent);
 
index 2a76c1e17593bc6737909ef5b02a3045ca47d58d..5b41235d9f730c277ada46615084224683813e61 100644 (file)
@@ -599,6 +599,14 @@ protected:
                               WXWPARAM wParam,
                               WXLPARAM lParam = 0) const;
 
+    // Another helper for creating wxKeyEvent for wxEVT_CHAR and related types.
+    //
+    // The wParam and lParam here must come from WM_CHAR event parameters, i.e.
+    // wParam must be a character and not a virtual code.
+    wxKeyEvent CreateCharEvent(wxEventType evType,
+                               WXWPARAM wParam,
+                               WXLPARAM lParam) const;
+
 
     // default OnEraseBackground() implementation, return true if we did erase
     // the background, false otherwise (i.e. the system should erase it)
index 8284b8212e827b4b3e6648ffc448bdedac0bd7e7..382b3ab50c8c54bd61ce489942be64273c18b025 100644 (file)
@@ -206,6 +206,7 @@ wxDEFINE_EVENT( wxEVT_AUX2_DCLICK, wxMouseEvent );
 
 // Character input event type
 wxDEFINE_EVENT( wxEVT_CHAR, wxKeyEvent );
+wxDEFINE_EVENT( wxEVT_AFTER_CHAR, wxKeyEvent );
 wxDEFINE_EVENT( wxEVT_CHAR_HOOK, wxKeyEvent );
 wxDEFINE_EVENT( wxEVT_NAVIGATION_KEY, wxNavigationKeyEvent );
 wxDEFINE_EVENT( wxEVT_KEY_DOWN, wxKeyEvent );
index 165c03c207403833de03d066b2de8ae08f67cdf1..0b1f0d3a3aacc0f50eff5227375e6108423f31d0 100644 (file)
@@ -2255,10 +2255,23 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
 
 WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
+    WXLRESULT rc;
     if ( m_oldWndProc )
-        return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
+        rc = ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
     else
-        return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
+        rc = ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
+
+    // Special hack used by wxTextEntry auto-completion only: this event is
+    // sent after the normal keyboard processing so that its handler could use
+    // the updated contents of the text control, after taking the key that was
+    // pressed into account.
+    if ( nMsg == WM_CHAR )
+    {
+        wxKeyEvent event(CreateCharEvent(wxEVT_AFTER_CHAR, wParam, lParam));
+        HandleWindowEvent(event);
+    }
+
+    return rc;
 }
 
 bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
@@ -5675,11 +5688,12 @@ wxWindowMSW::CreateKeyEvent(wxEventType evType,
     return event;
 }
 
-// isASCII is true only when we're called from WM_CHAR handler and not from
-// WM_KEYDOWN one
-bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam)
+wxKeyEvent
+wxWindowMSW::CreateCharEvent(wxEventType evType,
+                             WXWPARAM wParam,
+                             WXLPARAM lParam) const
 {
-    wxKeyEvent event(wxEVT_CHAR);
+    wxKeyEvent event(evType);
     InitAnyKeyEvent(event, wParam, lParam);
 
 #if wxUSE_UNICODE
@@ -5723,6 +5737,14 @@ bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam)
         event.m_altDown = false;
     }
 
+    return event;
+}
+
+// isASCII is true only when we're called from WM_CHAR handler and not from
+// WM_KEYDOWN one
+bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam)
+{
+    wxKeyEvent event(CreateCharEvent(wxEVT_CHAR, wParam, lParam));
     return HandleWindowEvent(event);
 }