X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/489468feaa08b8f504735eecca522fb8d0f825d2..817d057840b17a106f7b66e64ec2a7526e42dd20:/src/osx/carbon/srchctrl.cpp?ds=sidebyside diff --git a/src/osx/carbon/srchctrl.cpp b/src/osx/carbon/srchctrl.cpp index 4a78629391..0a7eb7a767 100644 --- a/src/osx/carbon/srchctrl.cpp +++ b/src/osx/carbon/srchctrl.cpp @@ -25,8 +25,8 @@ #if wxUSE_NATIVE_SEARCH_CONTROL -#include "wx/mac/uma.h" -#include "wx/mac/carbon/private/mactext.h" +#include "wx/osx/uma.h" +#include "wx/osx/carbon/private/mactext.h" BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase) END_EVENT_TABLE() @@ -66,6 +66,8 @@ public : virtual void SetDescriptiveText(const wxString& text); virtual wxString GetDescriptiveText() const; + + virtual bool SetFocus(); protected : virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf ); @@ -176,6 +178,21 @@ wxString wxMacSearchFieldControl::GetDescriptiveText() const } } +bool wxMacSearchFieldControl::SetFocus() +{ + // NB: We have to implement SetFocus a little differently because kControlFocusNextPart + // leads to setting the focus on the search icon rather than the text area. + // We get around this by explicitly telling the control to set focus to the + // text area. + + OSStatus err = SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, kControlEditTextPart ); + if ( err == errCouldntSetFocus ) + return false ; + SetUserFocusWindow(GetControlOwner( m_controlRef ) ); + return true; +} + + // ============================================================================ // implementation // ============================================================================ @@ -274,27 +291,6 @@ wxSize wxSearchCtrl::DoGetBestSize() const return size; } -void wxSearchCtrl::SetFocus() -{ - // NB: We have to implement SetFocus a little differently because kControlFocusNextPart - // leads to setting the focus on the search icon rather than the text area. - // We get around this by explicitly telling the control to set focus to the - // text area. - if ( !AcceptsFocus() ) - return ; - - wxWindow* former = FindFocus() ; - if ( former == this ) - return ; - - // as we cannot rely on the control features to find out whether we are in full keyboard mode, - // we can only leave in case of an error - OSStatus err = m_peer->SetFocus( kControlEditTextPart ) ; - if ( err == errCouldntSetFocus ) - return ; - - SetUserFocusWindow( (WindowRef)MacGetTopLevelWindowRef() ); -} // search control specific interfaces // wxSearchCtrl owns menu after this call