Never restore focus to hidden child.
Don't set focus to a hidden window in our focus management code, this never makes sense and results in apparent focus loss. It also fixes, as a side effect, a crash in wxGrid under wxMSW as the focus is not restored to the hidden grid editor any longer and so the code in its wxEVT_KILL_FOCUS handler that resulted in the crash is not executed any longer, see #13349. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -650,14 +650,26 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
|||||||
// It might happen that the window got reparented
|
// It might happen that the window got reparented
|
||||||
if ( (*childLastFocused)->GetParent() == win )
|
if ( (*childLastFocused)->GetParent() == win )
|
||||||
{
|
{
|
||||||
wxLogTrace(TRACE_FOCUS,
|
// And it also could have become hidden in the meanwhile, in this
|
||||||
wxT("SetFocusToChild() => last child (0x%p)."),
|
// case focus its parent instead.
|
||||||
(*childLastFocused)->GetHandle());
|
while ( !(*childLastFocused)->IsShown() )
|
||||||
|
{
|
||||||
|
*childLastFocused = (*childLastFocused)->GetParent();
|
||||||
|
if ( !*childLastFocused )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// not SetFocusFromKbd(): we're restoring focus back to the old
|
if ( *childLastFocused )
|
||||||
// window and not setting it as the result of a kbd action
|
{
|
||||||
(*childLastFocused)->SetFocus();
|
wxLogTrace(TRACE_FOCUS,
|
||||||
return true;
|
wxT("SetFocusToChild() => last child (0x%p)."),
|
||||||
|
(*childLastFocused)->GetHandle());
|
||||||
|
|
||||||
|
// not SetFocusFromKbd(): we're restoring focus back to the old
|
||||||
|
// window and not setting it as the result of a kbd action
|
||||||
|
(*childLastFocused)->SetFocus();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user