Forward WM_{CUT,COPY,PASTE} from edit control to wxComboBox in wxMSW too.

This allows us to receive wxClipboardTextEvents from wxComboBox as well.

Update the documentation to mention this.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-07-01 21:10:08 +00:00
parent efaad1f079
commit 75aaa4c5ac
2 changed files with 65 additions and 55 deletions

View File

@@ -2159,8 +2159,8 @@ public:
text was copied or cut. text was copied or cut.
@note @note
These events are currently only generated by wxTextCtrl under GTK+. These events are currently only generated by wxTextCtrl in wxGTK and wxOSX
They are generated by all controls under Windows. but are also generated by wxComboBox without wxCB_READONLY style in wxMSW.
@beginEventTable{wxClipboardTextEvent} @beginEventTable{wxClipboardTextEvent}
@event{EVT_TEXT_COPY(id, func)} @event{EVT_TEXT_COPY(id, func)}

View File

@@ -93,6 +93,36 @@ static WNDPROC gs_wndprocEdit = (WNDPROC)NULL;
// implementation // implementation
// ============================================================================ // ============================================================================
namespace
{
// Check if the given message should be forwarded from the edit control which
// is part of the combobox to wxComboBox itself. All messages generating the
// events that the code using wxComboBox could be interested in must be
// forwarded.
bool ShouldForwardFromEditToCombo(UINT message)
{
switch ( message )
{
case WM_KEYUP:
case WM_KEYDOWN:
case WM_CHAR:
case WM_SYSCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_SETFOCUS:
case WM_KILLFOCUS:
case WM_CUT:
case WM_COPY:
case WM_PASTE:
return true;
}
return false;
}
} // anonymous namespace
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wnd proc for subclassed edit control // wnd proc for subclassed edit control
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -105,18 +135,7 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
HWND hwndCombo = ::GetParent(hWnd); HWND hwndCombo = ::GetParent(hWnd);
wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo); wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo);
switch ( message ) if ( ShouldForwardFromEditToCombo(message) )
{
// forward some messages to the combobox to generate the appropriate
// wxEvents from them
case WM_KEYUP:
case WM_KEYDOWN:
case WM_CHAR:
case WM_SYSCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_SETFOCUS:
case WM_KILLFOCUS:
{ {
wxComboBox *combo = wxDynamicCast(win, wxComboBox); wxComboBox *combo = wxDynamicCast(win, wxComboBox);
if ( !combo ) if ( !combo )
@@ -135,9 +154,7 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
return 0; return 0;
} }
} }
break; else if ( message == WM_GETDLGCODE )
case WM_GETDLGCODE:
{ {
wxCHECK_MSG( win, 0, wxT("should have a parent") ); wxCHECK_MSG( win, 0, wxT("should have a parent") );
@@ -147,8 +164,6 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
return DLGC_WANTMESSAGE; return DLGC_WANTMESSAGE;
} }
} }
break;
}
return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam); return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
} }
@@ -235,22 +250,17 @@ bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam)
return true; return true;
} }
} }
// fall through // fall through, WM_CHAR is one of the message we should forward.
case WM_SYSCHAR: default:
case WM_SYSKEYDOWN: if ( ShouldForwardFromEditToCombo(msg) )
case WM_KEYDOWN: {
case WM_SYSKEYUP: // For all the messages forward from the edit control the
case WM_KEYUP: // result is not used.
case WM_SETFOCUS:
case WM_KILLFOCUS:
case WM_CUT:
case WM_COPY:
case WM_PASTE:
// For the messages above the result is not used.
WXLRESULT result; WXLRESULT result;
return MSWHandleMessage(&result, msg, wParam, lParam); return MSWHandleMessage(&result, msg, wParam, lParam);
} }
}
return false; return false;
} }