Discussion:
How to disable auto-scroll in wx >= 2.8.8 ? (bug #9563 ?)
Vincent Favre-Nicolin
16 years ago
Permalink
Hi,

I have a little problem with wx versions since 2.8.8 - the "When focus is
set to wxScrolledWindow child, scroll it into view" feature is turning out to
be very annoying in some circumstances.
This is related to bug #9563 (http://trac.wxwidgets.org/ticket/9563).

The auto-scrolling works correctly for whenever there are only small
sub-windows as children of a wxScrolledWindow. However if a group of controls
are grouped together as a wxWindow (which is one children of the
wxScrolledWindow) it behaves strangely. This is probably true whenever a
children window is large enough not to fit in the scrolled window.

I have attached an example, which can be compiled by replacing minimal.cpp.
This was tested with wxGTK, but I've seen the same behaviour under windows
and MacOSX.
In this example there are 3 independent buttons and 3 others that are
embedded in a sub-window (SubWin)

Here are a few undesired ways the window is auto-scrolled:
1) launch the minimal window , click right *below* the "SubButton1": the
window scrolls down to the bottom of SubWin
2) click on sub-button 1: the window scrolls down to the bottom of SubWin
3) Click on sub-button 1. Then resize the window to a smaller size and repeat.
Each time resizing the window will alternatively re-scroll to the bottom or
the top of SubWin...
4) launch the minimal window. Click on sub-button 1, or below sub-button 2
(this puts the SubWin in focus). Then move the window by click&drag the top
of the window frame. Every time the window is moved the window will
alternatively re-scroll to the bottom or the top of SubWin...

While I'm sure there are good reasons for auto-scrolling (when scrolling a
little to move a smallcontrol in view), in circumstances like above it does
not work well. So I'd very much like a way to de-activate that feature.

Being able to deactivate it is particularly important as it was added to a
minor release (2.8.x) and linux distributions are now shipping with 2.8.9 - I
have to find a way around this - going back to 2.6 is not an option.

regards,
Vincent
--
Vincent Favre-Nicolin

CEA Grenoble/INAC/SP2M http://inac.cea.fr
Univ. Joseph Fourier (Grenoble) http://www.ujf-grenoble.fr

ObjCryst & Fox http://objcryst.sf.net/Fox
Vincent Favre-Nicolin
16 years ago
Permalink
Further note: I made the tests described in the previous email on wxGTK 2.8.10

Vincent
--
Vincent Favre-Nicolin

CEA Grenoble/INAC/SP2M http://inac.cea.fr
Univ. Joseph Fourier (Grenoble) http://www.ujf-grenoble.fr

ObjCryst & Fox http://objcryst.sf.net/Fox
Marek Bronowicki
16 years ago
Permalink
I think I got the same annoying thing:)
I made after tons of searching something like this:

In src/generic/scrlwing.cpp
lines from 1381 to 1387 in the original looks like this:

wxWindow *actual_focus=wxWindow::FindFocus();
if (win != actual_focus &&
wxDynamicCast(win, wxPanel) != 0 &&
win->GetParent() == m_targetWindow)
// if win is a wxPanel and receives the focus, it should not be
// scrolled into view
return;

I made three lines of comment like this.
wxWindow *actual_focus=wxWindow::FindFocus();
// if (win != actual_focus &&
// wxDynamicCast(win, wxPanel) != 0 &&
// win->GetParent() == m_targetWindow)
// if win is a wxPanel and receives the focus, it should not be
// scrolled into view
return;

And voila. There is no more hard to figure-out jumping.
I don't know what it does, but I don't need these 3 lines that's for sure:-)

Hope it helps.

Best Regards,
Marek Bronowicki
Post by Vincent Favre-Nicolin
Further note: I made the tests described in the previous email on wxGTK 2.8.10
Vincent
------------------------------------------------------------------------
Nie znaleziono wirusa w tej wiadomoťci przychodzćcej.
Sprawdzone przez AVG - www.avg.com
Wersja: 8.0.238 / Baza danych wirusôw: 270.11.31/2028 - Data wydania: 03/28/09 07:16:00
Jaakko Salli
16 years ago
Permalink
Hi,

A little less intrusive workaround would be to add an empty
EVT_CHILD_FOCUS handler in a subclassed wxScrolledWindow. Only
problem with this approach is that other things relying on
EVT_CHILD_FOCUS may not work. For instance, AUI cannot detect the
panel focus correctly in this case.

HTH,
Jaakko
Post by Marek Bronowicki
I think I got the same annoying thing:)
[snip]
...
Vincent Favre-Nicolin
16 years ago
Permalink
Hi,

Thanks for your answers !
Post by Marek Bronowicki
I think I got the same annoying thing:)
In src/generic/scrlwing.cpp
[...]
Post by Marek Bronowicki
I made three lines of comment like this.
[...]

Unfortunately changing the scrlwing code is not an option - I need this to
work when using shared wx libraries...
Post by Marek Bronowicki
A little less intrusive workaround would be to add an empty
EVT_CHILD_FOCUS handler in a subclassed wxScrolledWindow. Only
problem with this approach is that other things relying on
EVT_CHILD_FOCUS may not work. For instance, AUI cannot detect the
panel focus correctly in this case.
Yes, I thought about doing that, but losing all focus events may be too
much to lose.

It seems the only answer would be to derive both wxScrolledWindow and
wxScrollHelper - copying scrolwin.h and scrolwing.cpp and commenting a few
lines ?

regards,
Vincent
--
Vincent Favre-Nicolin

CEA Grenoble/INAC/SP2M http://inac.cea.fr
Univ. Joseph Fourier (Grenoble) http://www.ujf-grenoble.fr

ObjCryst & Fox http://objcryst.sf.net/Fox
Jaakko Salli
16 years ago
Permalink
Vincent,
Post by Vincent Favre-Nicolin
Post by Jaakko Salli
A little less intrusive workaround would be to add an empty
EVT_CHILD_FOCUS handler in a subclassed wxScrolledWindow. Only
problem with this approach is that other things relying on
EVT_CHILD_FOCUS may not work. For instance, AUI cannot detect the
panel focus correctly in this case.
Yes, I thought about doing that, but losing all focus events may be too
much to lose.
You don't lose all focus events, just wxEVT_CHILD_FOCUS. I've used
this workaround in wxPropertyGrid component for almost a year now,
and only problem with it thus far has been the aforementioned issue
with the AUI pane focus. For more information, see:

http://sourceforge.net/tracker/?func=detail&aid=2619204&group_id=133406&atid=727081

Regards,
Jaakko

Loading...