Problem with CaptureMouse and windows that scrolls Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
jsoldi
Experienced Solver
Experienced Solver
Posts: 73
Joined: Thu Feb 02, 2006 6:03 am

Problem with CaptureMouse and windows that scrolls

Post by jsoldi » Tue May 16, 2006 4:28 pm

When I capture the mouse in a window, and the window has scroll bars and a bigger content than the one I can see on the window, when I move the mouse outside the window, the content starts moving, as well as the scroll bars. This is exactly what I want to happen, but the movement is to slow, I need the content to move faster. If there is a way to tell wxWidgets to do that it would be great, but I think I'll have to do it my self. I've tryed to do it by calling SetScrollPos and by moving the content by the same amount I move the scrolls, but seems that wxWidgets is still trying to move the scrolls pixel by pixel so my window looks like an earthquake, where everybody is trying to move it on a diferent way. Is there any way to tell wxWidgets to stop moving my scrolls?

achim
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Sun Aug 29, 2004 5:20 pm
Location: Germany

Post by achim » Tue May 16, 2006 4:49 pm

some informations could be helpful:
the window scrolls, when you move your mouse outside it?
guess mouse button(s) are peessed meanwhile?
what kind of window is it?
do you catch any events?

cheers
achim

jsoldi
Experienced Solver
Experienced Solver
Posts: 73
Joined: Thu Feb 02, 2006 6:03 am

Post by jsoldi » Tue May 16, 2006 8:18 pm

Yes, the windows scrolls when I move the mouse outside it, and the left button is pressed. The window is derived from wxScrolledWindow, and I catch the events EVT_LEFT_DOWN, EVT_LEFT_UP and EVT_MOTION. By the way, I've written the code that tries to scroll the window in the EVT_MOTION event handler.

achim
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Sun Aug 29, 2004 5:20 pm
Location: Germany

Post by achim » Tue May 16, 2006 10:23 pm

I'm still in the dark, but
I've written the code that tries to scroll the window in the EVT_MOTION event handler.
, let assume that the transformation of mousespeed to scrollspeed might be in disorder?
I could guess your code, but...

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Tue May 16, 2006 10:52 pm

wxScrolledWindow is scrolling single lines which is exactly what it should do. If you want it to move more than a pixel set your scroll increment to something bigger than a pixel (using SetScrollRate).

Changing this behavior is somewhat complicated but the meat of it is in scrlwing.cpp (wxAutoScrollTimer and wxScrollHelper::HandleMouseLeave). Personally, I'd recommend just increasing your scroll rate though. 1 pixel scroll rates are annoying for users.

jsoldi
Experienced Solver
Experienced Solver
Posts: 73
Joined: Thu Feb 02, 2006 6:03 am

Post by jsoldi » Wed May 17, 2006 3:53 am

I think I've found the solution: just handle the event EVT_LEAVE_WINDOW, and call Skip(false) in the event handler, so wxWidgets stops scrolling the window, and then (this is what I haven't done yet) do a code that scrolls the window by the amount I want.

jsoldi
Experienced Solver
Experienced Solver
Posts: 73
Joined: Thu Feb 02, 2006 6:03 am

Post by jsoldi » Wed May 17, 2006 4:30 am

Now I have a new problem: Where do I'm supposed to implement the code that scrolls the window when the mouse is outside it? If I do it in the EVT_MOTION handler, the windows only scrolls when I move the mouse outside the window, while it should do it every time the mouse *is* outside the window. Is there any EVT_MOUSE_IS_STILL_OUTSIDE event or something like that, or anything else I can do?

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Thu May 18, 2006 12:08 am

Nope, there is no EVT_MOUSE_IS_STILL_OUTSIDE event. wxScrolledWindow does it using a derived wxTimer that continually fires until an EVT_ENTER_WINDOW occurs.

Post Reply