X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d15694e8cad1d44087323bd568ca33ff5b354f2c..f86a4930f2c69058684496a1882343fe8e709bf2:/src/osx/textctrl_osx.cpp diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 0af4f04bcc..e513b16b7e 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -154,11 +154,6 @@ void wxTextCtrl::MacCheckSpelling(bool check) GetTextPeer()->CheckSpelling(check); } -void wxTextCtrl::SetMaxLength(unsigned long len) -{ - m_maxLength = len ; -} - bool wxTextCtrl::SetFont( const wxFont& font ) { if ( !wxTextCtrlBase::SetFont( font ) ) @@ -290,7 +285,7 @@ void wxTextCtrl::Copy() { if (CanCopy()) { - wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_COPY, GetId()); + wxClipboardTextEvent evt(wxEVT_TEXT_COPY, GetId()); evt.SetEventObject(this); if (!GetEventHandler()->ProcessEvent(evt)) { @@ -303,7 +298,7 @@ void wxTextCtrl::Cut() { if (CanCut()) { - wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_CUT, GetId()); + wxClipboardTextEvent evt(wxEVT_TEXT_CUT, GetId()); evt.SetEventObject(this); if (!GetEventHandler()->ProcessEvent(evt)) { @@ -318,7 +313,7 @@ void wxTextCtrl::Paste() { if (CanPaste()) { - wxClipboardTextEvent evt(wxEVT_COMMAND_TEXT_PASTE, GetId()); + wxClipboardTextEvent evt(wxEVT_TEXT_PASTE, GetId()); evt.SetEventObject(this); if (!GetEventHandler()->ProcessEvent(evt)) { @@ -339,7 +334,7 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) void wxTextCtrl::OnKeyDown(wxKeyEvent& event) { - if ( event.GetModifiers() == wxMOD_CMD ) + if ( event.GetModifiers() == wxMOD_CONTROL ) { switch( event.GetKeyCode() ) { @@ -381,18 +376,21 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) return ; } - // Check if we have reached the max # of chars (if it is set), but still - // allow navigation and deletion - GetSelection( &from, &to ); - if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength && - !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) && - !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) && - from == to ) + if ( !GetTextPeer()->CanClipMaxLength() ) { - // eat it, we don't want to add more than allowed # of characters + // Check if we have reached the max # of chars (if it is set), but still + // allow navigation and deletion + GetSelection( &from, &to ); + if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength && + !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) && + !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) && + from == to ) + { + // eat it, we don't want to add more than allowed # of characters - // TODO: generate EVT_TEXT_MAXLEN() - return; + // TODO: generate EVT_TEXT_MAXLEN() + return; + } } // assume that any key not processed yet is going to modify the control @@ -403,7 +401,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) case WXK_RETURN: if (m_windowStyle & wxTE_PROCESS_ENTER) { - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); + wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); event.SetEventObject( this ); event.SetString( GetValue() ); if ( HandleWindowEvent(event) ) @@ -418,7 +416,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if ( def && def->IsEnabled() ) { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); + wxCommandEvent event(wxEVT_BUTTON, def->GetId() ); event.SetEventObject(def); def->Command(event); @@ -471,7 +469,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) key == WXK_DELETE || key == WXK_BACK) { - wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); + wxCommandEvent event1(wxEVT_TEXT, m_windowId); event1.SetEventObject( this ); wxPostEvent( GetEventHandler(), event1 ); } @@ -775,9 +773,10 @@ int wxTextWidgetImpl::GetLineLength(long lineNo) const count = 0; for (size_t j = i; j < content.length(); j++) { - count++; if (content[j] == '\n') return count; + + count++; } return count;