fixed processing of the implicit wxTextCtrl accelerators (Ctrl-C/V/X)
without breaking all the others by using a new MSWShouldPreProcessMessage() function git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11282 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -172,6 +172,8 @@ protected:
|
|||||||
// limit is big enough)
|
// limit is big enough)
|
||||||
void AdjustSpaceLimit();
|
void AdjustSpaceLimit();
|
||||||
|
|
||||||
|
// override some base class virtuals
|
||||||
|
virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -347,8 +347,20 @@ public:
|
|||||||
|
|
||||||
// Calls an appropriate default window procedure
|
// Calls an appropriate default window procedure
|
||||||
virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
virtual long MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||||
|
|
||||||
|
// message processing helpers
|
||||||
|
|
||||||
|
// return FALSE if the message shouldn't be translated/preprocessed but
|
||||||
|
// dispatched normally
|
||||||
|
virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
|
||||||
|
|
||||||
|
// return TRUE if the message was preprocessed and shouldn't be dispatched
|
||||||
virtual bool MSWProcessMessage(WXMSG* pMsg);
|
virtual bool MSWProcessMessage(WXMSG* pMsg);
|
||||||
|
|
||||||
|
// return TRUE if the message was translated and shouldn't be dispatched
|
||||||
virtual bool MSWTranslateMessage(WXMSG* pMsg);
|
virtual bool MSWTranslateMessage(WXMSG* pMsg);
|
||||||
|
|
||||||
|
// called when the window is about to be destroyed
|
||||||
virtual void MSWDestroyWindow();
|
virtual void MSWDestroyWindow();
|
||||||
|
|
||||||
// Detach "Window" menu from menu bar so it doesn't get deleted
|
// Detach "Window" menu from menu bar so it doesn't get deleted
|
||||||
|
@@ -1079,6 +1079,14 @@ bool wxApp::ProcessMessage(WXMSG *wxmsg)
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
|
// allow the window to prevent certain messages from being
|
||||||
|
// translated/processed (this is currently used by wxTextCtrl to always
|
||||||
|
// grab Ctrl-C/V/X, even if they are also accelerators in some parent)
|
||||||
|
if ( !wndThis->MSWShouldPreProcessMessage(wxmsg) )
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// try translations first: the accelerators override everything
|
// try translations first: the accelerators override everything
|
||||||
wxWindow *wnd;
|
wxWindow *wnd;
|
||||||
|
|
||||||
@@ -1094,13 +1102,16 @@ bool wxApp::ProcessMessage(WXMSG *wxmsg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now try the other hooks (kbd navigation is handled here)
|
// now try the other hooks (kbd navigation is handled here): we start from
|
||||||
for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
|
// wndThis->GetParent() because wndThis->MSWProcessMessage() was already
|
||||||
|
// called above
|
||||||
|
for ( wnd = wndThis->GetParent(); wnd; wnd = wnd->GetParent() )
|
||||||
{
|
{
|
||||||
if ( wnd->MSWProcessMessage(wxmsg) )
|
if ( wnd->MSWProcessMessage(wxmsg) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no special preprocessing for this message, dispatch it normally
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -928,6 +928,52 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// kbd input processing
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* pMsg)
|
||||||
|
{
|
||||||
|
MSG *msg = (MSG *)pMsg;
|
||||||
|
|
||||||
|
// check for our special keys here: if we don't do it and the parent frame
|
||||||
|
// uses them as accelerators, they wouldn't work at all, so we disable
|
||||||
|
// usual preprocessing for them
|
||||||
|
if ( msg->message == WM_KEYDOWN )
|
||||||
|
{
|
||||||
|
WORD vkey = msg->wParam;
|
||||||
|
if ( (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
|
||||||
|
{
|
||||||
|
if ( vkey == VK_BACK )
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else // no Alt
|
||||||
|
{
|
||||||
|
if ( wxIsCtrlDown() )
|
||||||
|
{
|
||||||
|
switch ( vkey )
|
||||||
|
{
|
||||||
|
case 'C':
|
||||||
|
case 'V':
|
||||||
|
case 'X':
|
||||||
|
case VK_INSERT:
|
||||||
|
case VK_DELETE:
|
||||||
|
case VK_HOME:
|
||||||
|
case VK_END:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( wxIsShiftDown() )
|
||||||
|
{
|
||||||
|
if ( vkey == VK_INSERT || vkey == VK_DELETE )
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxControl::MSWShouldPreProcessMessage(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
switch ( event.KeyCode() )
|
switch ( event.KeyCode() )
|
||||||
|
@@ -1958,6 +1958,12 @@ bool wxWindowMSW::MSWTranslateMessage(WXMSG* pMsg)
|
|||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg)
|
||||||
|
{
|
||||||
|
// preprocess all messages by default
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// message params unpackers (different for Win16 and Win32)
|
// message params unpackers (different for Win16 and Win32)
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user