From 527b35a84dcb6bde77b47dee7d24ca33dd9348a5 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 30 Nov 2007 05:52:24 +0000 Subject: [PATCH] wxCocoa only: Give the buddy text control focus if the user changes the spinner. Copyright 2007 Software 2000 Ltd. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@50335 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/spinctlg.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index 88de174cfd..6e70acb1f7 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -319,6 +319,22 @@ void wxSpinCtrl::SetTextValue(int val) // and give focus to the control! // m_text->SetFocus(); Why???? TODO. + +#ifdef __WXCOCOA__ + /* It's sort of a hack to do this from here but the idea is that if the + user has clicked on us, which is the main reason this method is called, + then focus probably ought to go to the text control since clicking on + a text control usually gives it focus. + + However, if the focus is already on us (i.e. the user has turned on + the ability to tab to controls) then we don't want to drop focus. + So we only set focus if we would steal it away from a different + control, not if we would steal it away from ourself. + */ + wxWindow *currentFocusedWindow = wxWindow::FindFocus(); + if(currentFocusedWindow != this && currentFocusedWindow != m_text) + m_text->SetFocus(); +#endif } void wxSpinCtrl::SetValue(int val)