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:
@@ -83,6 +83,8 @@ public:
|
|||||||
|
|
||||||
wxMacSearchFieldControl * GetPeer() const
|
wxMacSearchFieldControl * GetPeer() const
|
||||||
{ return (wxMacSearchFieldControl*) m_peer; }
|
{ return (wxMacSearchFieldControl*) m_peer; }
|
||||||
|
|
||||||
|
virtual void SetFocus();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -261,7 +261,34 @@ wxSearchCtrl::~wxSearchCtrl()
|
|||||||
|
|
||||||
wxSize wxSearchCtrl::DoGetBestSize() const
|
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
|
// search control specific interfaces
|
||||||
|
Reference in New Issue
Block a user