X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/519cb848a8f4c91c73421bb75314754284e593a4..79f585d90388128f9d245f7c92d3013b98b9ed14:/src/mac/textctrl.cpp?ds=sidebyside diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index d553477f93..c1b98861b0 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -38,14 +38,12 @@ #include "wx/mac/uma.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_CHAR(wxTextCtrl::OnChar) END_EVENT_TABLE() -#endif // Text item wxTextCtrl::wxTextCtrl() @@ -409,73 +407,51 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) void wxTextCtrl::OnChar(wxKeyEvent& event) { - bool handleIt = true ; switch( event.KeyCode() ) { case WXK_RETURN: { -/* Oh yes it will, because we also specify DLGC_WANTCHARS - wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER, - "this text ctrl should never receive return" ); -*/ - - if ( (m_windowStyle & wxTE_MULTILINE) == 0 ) + if ( !(m_windowStyle & wxTE_MULTILINE) ) { - wxWindow* parent = GetParent() ; - while( parent ) - { - if ( parent->GetDefaultItem() ) - { - wxButton *defaultBtn = parent->GetDefaultItem() ; - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() ); - event.SetEventObject(defaultBtn); - defaultBtn->Command(event); - return ; - } - parent = parent->GetParent() ; - } ; + wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); + event.SetEventObject( this ); + if ( GetEventHandler()->ProcessEvent(event) ) + return; } + //else: multiline controls need Enter for themselves + break; } case WXK_TAB: - // only produce navigation event if we don't process TAB ourself or - // if it's a Shift-Tab keypress (we assume nobody will ever need - // this key combo for himself) + // always produce navigation event - even if we process TAB + // ourselves the fact that we got here means that the user code + // decided to skip processing of this TAB - probably to let it + // do its default job. // // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is // handled by Windows - if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) ) { wxNavigationKeyEvent eventNav; eventNav.SetDirection(!event.ShiftDown()); eventNav.SetWindowChange(FALSE); eventNav.SetEventObject(this); - + if ( GetEventHandler()->ProcessEvent(eventNav) ) return; } break; + + default: + event.Skip(); + return; } - if ( handleIt ) - { - EventRecord *ev = wxTheApp->MacGetCurrentEvent() ; - short keycode ; - short keychar ; - keychar = short(ev->message & charCodeMask); - keycode = short(ev->message & keyCodeMask) >> 8 ; - UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ; - if ( keychar >= 0x20 ) - { - { - wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); - wxString val(GetValue()); - if ( !val.IsNull() ) - event.m_commandString = WXSTRINGCAST val; - event.SetEventObject( this ); - ProcessCommand(event); - } - } - } + + // don't just call event.Skip() because this will cause TABs and ENTERs + // be passed upwards and we don't always want this - instead process it + // right here + + // FIXME + event.Skip(); } // The streambuf code was partly taken from chapter 3 by Jerry Schwarz of // AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers