Fix spurious scrolling with deeply nested control
The original ticket #9563 about children inside a wxScrolledWindow being scrolled, instead of just handling the mouse click (e.g. by toggling the checkbox), was fixed some time ago when the child was a direct child of wxPanel. However the same problem still existed when the child was inside another window which was itself a child of wxPanel. Generalize the fix by ignoring the child focus event if any of the window ancestors passes our check instead of checking only the window itself. Closes #17154.
This commit is contained in:
committed by
Vadim Zeitlin
parent
60bd6842e4
commit
69110bd470
@@ -1079,22 +1079,28 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event)
|
|||||||
// window again to make the child widget visible. This leads to ugly
|
// window again to make the child widget visible. This leads to ugly
|
||||||
// flickering when using nested wxPanels/wxScrolledWindows.
|
// flickering when using nested wxPanels/wxScrolledWindows.
|
||||||
//
|
//
|
||||||
// Ignore this event if 'win' is derived from wxControlContainer AND its
|
// Ignore this event if 'win', or any of its ancestors, is derived from
|
||||||
// parent is the m_targetWindow AND 'win' is not actually reciving the
|
// wxControlContainer AND its parent is the m_targetWindow AND 'win' is not
|
||||||
// focus (win != FindFocus). TODO: This affects all wxControlContainer
|
// actually receiving the focus (win != FindFocus).
|
||||||
// objects, but wxControlContainer is not part of the wxWidgets RTTI and
|
//
|
||||||
// so wxDynamicCast(win, wxControlContainer) does not compile. Find a way
|
// TODO: This affects all wxControlContainer objects, but
|
||||||
// to determine if 'win' derives from wxControlContainer. Until then,
|
// wxControlContainer is not part of the wxWidgets RTTI and so
|
||||||
// testing if 'win' derives from wxPanel will probably get >90% of all
|
// wxDynamicCast(win, wxControlContainer) does not compile. Find a way to
|
||||||
// cases.
|
// determine if 'win' derives from wxControlContainer. Until then, testing
|
||||||
|
// if 'win' derives from wxPanel will probably get >90% of all cases.
|
||||||
|
|
||||||
wxWindow *actual_focus=wxWindow::FindFocus();
|
wxWindow * const actual_focus = wxWindow::FindFocus();
|
||||||
if (win != actual_focus &&
|
for ( wxWindow* w = win; w; w = w->GetParent() )
|
||||||
wxDynamicCast(win, wxPanel) != 0 &&
|
{
|
||||||
win->GetParent() == m_targetWindow)
|
if ( w != actual_focus &&
|
||||||
// if win is a wxPanel and receives the focus, it should not be
|
wxDynamicCast(w, wxPanel) != NULL &&
|
||||||
// scrolled into view
|
w->GetParent() == m_targetWindow )
|
||||||
return;
|
{
|
||||||
|
// if it is a wxPanel and receives the focus, it should not be
|
||||||
|
// scrolled into view
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const wxRect viewRect(m_targetWindow->GetClientRect());
|
const wxRect viewRect(m_targetWindow->GetClientRect());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user