X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c84030e020e56735cb4b7c1534e99d21a8bb48c0..6178debcd342963974dbdce6ac2ddb2fbe89e42a:/src/osx/textctrl_osx.cpp diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 5bef77a56d..e7e82f21c2 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -53,6 +53,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_CHAR(wxTextCtrl::OnChar) + EVT_KEY_DOWN(wxTextCtrl::OnKeyDown) EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy) EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste) @@ -75,12 +76,9 @@ END_EVENT_TABLE() void wxTextCtrl::Init() { - m_editable = true ; m_dirty = false; - m_maxLength = 0; m_privateContextMenu = NULL; - m_triggerUpdateEvents = true ; } wxTextCtrl::~wxTextCtrl() @@ -138,11 +136,6 @@ bool wxTextCtrl::Create( wxWindow *parent, return true; } -wxTextWidgetImpl* wxTextCtrl::GetTextPeer() const -{ - return dynamic_cast (m_peer); -} - void wxTextCtrl::MacSuperChangedPosition() { wxWindow::MacSuperChangedPosition() ; @@ -295,33 +288,31 @@ wxString wxTextCtrl::GetLineText(long lineNo) const return GetTextPeer()->GetLineText(lineNo) ; } -void wxTextCtrl::Remove(long from, long to) -{ - wxTextEntry::Remove(from, to); - if ( m_triggerUpdateEvents ) - SendTextUpdatedEvent(); -} - -void wxTextCtrl::WriteText(const wxString& str) +void wxTextCtrl::Copy() { - wxTextEntry::WriteText( str ) ; - if ( m_triggerUpdateEvents ) - SendTextUpdatedEvent(); -} - -void wxTextCtrl::Clear() -{ - wxTextEntry::Clear() ; - SendTextUpdatedEvent(); + if (CanCopy()) + { + wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId()); + evt.SetEventObject(this); + if (!GetEventHandler()->ProcessEvent(evt)) + { + wxTextEntry::Copy(); + } + } } void wxTextCtrl::Cut() { if (CanCut()) { - wxTextEntry::Cut() ; + wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_CUT, GetId()); + evt.SetEventObject(this); + if (!GetEventHandler()->ProcessEvent(evt)) + { + wxTextEntry::Cut(); - SendTextUpdatedEvent(); + SendTextUpdatedEvent(); + } } } @@ -329,10 +320,15 @@ void wxTextCtrl::Paste() { if (CanPaste()) { - wxTextEntry::Paste(); + wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_PASTE, GetId()); + evt.SetEventObject(this); + if (!GetEventHandler()->ProcessEvent(evt)) + { + wxTextEntry::Paste(); - // TODO: eventually we should add setting the default style again - SendTextUpdatedEvent(); + // TODO: eventually we should add setting the default style again + SendTextUpdatedEvent(); + } } } @@ -343,27 +339,41 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) LoadFile( event.GetFiles()[0] ); } +void wxTextCtrl::OnKeyDown(wxKeyEvent& event) +{ + if ( event.GetModifiers() == wxMOD_CMD ) + { + switch( event.GetKeyCode() ) + { + case 'A': + SelectAll(); + return; + case 'C': + if ( CanCopy() ) + Copy() ; + return; + case 'V': + if ( CanPaste() ) + Paste() ; + return; + case 'X': + if ( CanCut() ) + Cut() ; + return; + default: + break; + } + } + // no, we didn't process it + event.Skip(); +} + void wxTextCtrl::OnChar(wxKeyEvent& event) { int key = event.GetKeyCode() ; bool eat_key = false ; long from, to; - if ( key == 'a' && event.MetaDown() ) - { - SelectAll() ; - - return ; - } - - if ( key == 'c' && event.MetaDown() ) - { - if ( CanCopy() ) - Copy() ; - - return ; - } - if ( !IsEditable() && !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB) && !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) ) // && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END @@ -390,22 +400,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // assume that any key not processed yet is going to modify the control m_dirty = true; - if ( key == 'v' && event.MetaDown() ) - { - if ( CanPaste() ) - Paste() ; - - return ; - } - - if ( key == 'x' && event.MetaDown() ) - { - if ( CanCut() ) - Cut() ; - - return ; - } - switch ( key ) { case WXK_RETURN: