wxMSW: generate wxClipboardTextEvent from wxTextCtrl with wxTE_RICH style too

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-03-15 12:28:03 +00:00
parent 6a70b5f1b9
commit e2cf30aa1c
3 changed files with 34 additions and 3 deletions

View File

@@ -248,6 +248,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
EVT_CHAR(wxTextCtrl::OnChar)
EVT_KEY_DOWN(wxTextCtrl::OnKeyDown)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
#if wxUSE_RICHEDIT
@@ -1846,6 +1847,35 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
event.Skip();
}
void wxTextCtrl::OnKeyDown(wxKeyEvent& event)
{
// richedit control doesn't send WM_PASTE, WM_CUT and WM_COPY messages
// when Ctrl-V, X or C is pressed and this prevents wxClipboardTextEvent
// from working. So we work around it by intercepting these shortcuts
// ourselves and emitting clipboard events (which richedit will handle,
// so everything works as before, including pasting of rich text):
if ( event.GetModifiers() == wxMOD_CONTROL && IsRich() )
{
switch ( event.GetKeyCode() )
{
case 'C':
Copy();
return;
case 'X':
Cut();
return;
case 'V':
Paste();
return;
default:
break;
}
}
// no, we didn't process it
event.Skip();
}
WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
WXLRESULT lRc = wxTextCtrlBase::MSWWindowProc(nMsg, wParam, lParam);