Improve default wxSearchCtrl GetBestSize() width and ensure that SetFocus focuses in the control's text area.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43911 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2006-12-11 07:35:46 +00:00
parent bda4b4c684
commit 698db322d0
2 changed files with 30 additions and 1 deletions

View File

@@ -83,6 +83,8 @@ public:
wxMacSearchFieldControl * GetPeer() const
{ return (wxMacSearchFieldControl*) m_peer; }
virtual void SetFocus();
protected:

View File

@@ -261,7 +261,34 @@ wxSearchCtrl::~wxSearchCtrl()
wxSize wxSearchCtrl::DoGetBestSize() const
{
return wxWindow::DoGetBestSize();
wxSize size = wxWindow::DoGetBestSize();
// it seems to return a default width of about 16, which is way too small here.
if (size.GetWidth() < 100)
size.SetWidth(100);
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