The Artima Developer Community
Sponsored Link

Java Answers Forum
Continuous Scrolling

4 replies on 1 page. Most recent reply: Mar 20, 2003 3:54 PM by Rich Burgis

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Rich Burgis

Posts: 17
Nickname: songbird
Registered: Mar, 2003

Continuous Scrolling Posted: Mar 17, 2003 6:24 PM
Reply to this message Reply
Advertisement
I am building an application that consists of a number of cells that extend far beyond the limits of the screen. I would like to be able to scroll through the rows and columns by moving the mouse past the limits of the canvas as can be done in Excel among others. (Best would be if I could speed up scrolling based on how far past the limit I get.)

The problem I see is that when I do that I only get one message from the mouse, when it exits the canvas. That lets me begin the scroll but without more messages, or more information about the state of the mouse I can't keep it moving.

Does anyone know of a way to poll the mouse or get the information in another way?

Thanks
Rich


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Continuous Scrolling Posted: Mar 18, 2003 6:08 PM
Reply to this message Reply
Excel and other Windows apps do this with the SetCapture() function. It asks Windows to keep sending all mouse events to your window until further notice, even when the mouse is outside your window. I haven't done this with Java, don't know if it is possible to do this in pure Java... But... look at the documentation of the MouseMotionListener interface's mouseDragged() method -- it looks like it will do the trick. It says you will continue to get events while the mouse is held down, even if you leave the bounds of the control.

Rich Burgis

Posts: 17
Nickname: songbird
Registered: Mar, 2003

Re: Continuous Scrolling Posted: Mar 19, 2003 6:49 PM
Reply to this message Reply
Thanks for the suggestion. I had thought that I tried it but figured that I should try it again.

What I found was that it would send me messages as long as I was dragging the mouse, but if I just held it down, inside the component or outside of the component, I get no messages. So I can't use this to control scrolling.

The best that I can see is a complicated scheme using a thread that starts when the mouse leaves the component and stops when the mouse moves back into the component. Then I can update it with the mouse location from the mouseDragged method. Then that can control the scrolling.

I'm just not thrilled with the prospect, but if it is all there is I guess I can try it.

Thanks again
Rich

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Continuous Scrolling Posted: Mar 19, 2003 7:02 PM
Reply to this message Reply
I don't understand. Seems to me that scolling speed is relative to the position of the mouse, not the movement. Although it is interesting to note that because of a bug in the way that the OnIdle event is dealt with in Windows (or is it just MFC?), many apps will scroll faster when you wiggle the mouse around outside their window, then they will when you hold the mouse still.

Anyhow, back to your problem. If you track the fact that the mouse is still down (meaning scrolling should continue) and where it is, why does it matter whether it is moving? The speed of the scroll is relative to the current mouse position, so if that hasn't changed, keep the scroll speed constant.

Rich Burgis

Posts: 17
Nickname: songbird
Registered: Mar, 2003

Re: Continuous Scrolling Posted: Mar 20, 2003 3:54 PM
Reply to this message Reply
I agree. The problem is that I currently depend on mouse messages to tell me to scroll. And if the mouse doesn't move I don't get any messages. So failing that, it seems I need to set up a separate thread to automatically scroll as long as the mouse hasn't been released.

The idea being that if I can't depend on mouse messages, I'll need to use a timer instead.

Of course a less complicated solution would be better.

Thanks
Rich

> I don't understand. Seems to me that scolling speed is
> relative to the position of the mouse, not the movement.
> Anyhow, back to your problem. If you track the fact that
> the mouse is still down (meaning scrolling should
> continue) and where it is, why does it matter whether it
> is moving? The speed of the scroll is relative to the
> current mouse position, so if that hasn't changed, keep
> the scroll speed constant.

Flat View: This topic has 4 replies on 1 page
Topic: Java Question Previous Topic   Next Topic Topic: using DFA

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use