Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Modifying Mouse Points during a Tracker loop
Modifying Mouse Points during a Tracker loop [message #449349] Sun, 23 January 2005 06:02 Go to next message
Joe Mihalich is currently offline Joe MihalichFriend
Messages: 25
Registered: July 2009
Junior Member
Hi,

I'm writing a pretty heavily GUI instensive network configuration
application. My view where I'm laying stuff out has grid snapping support.
When I place new items down, I use the Tracker class to draw a rectangle
the size of the object as they move the mouse, so they can place it
somewhere.

I would like to be ably to override where the tracker draws the
rectangle during a mouse move event...by snapping the mouse location to
the correct spot, and then drawing the rectangle there.

I've tried everything I could think of (which all seemed like hacks
that I shouldn't be doing) by adding a mouse move listener, or a control
listener (control moved)...but nothing is really working correctly.

Is there any way I can get Tracker to "snap" the mouse points? I can
write the rectangle drawing code myself if I have to, but I'd like to
figure out how to get this class to make it work.

Thanks,
Joe
Re: Modifying Mouse Points during a Tracker loop [message #449350 is a reply to message #449349] Sun, 23 January 2005 06:37 Go to previous messageGo to next message
Joe Mihalich is currently offline Joe MihalichFriend
Messages: 25
Registered: July 2009
Junior Member
Btw, after taking a look at the tracker source code, I should elaborate
on my "hacks", since one of them seems to be supported in the code.

The first thing I tried was adding a control listener to the tracker.
On the control moved handler method, I got the rectangle I set on the
tracker (getRectangles), which had been updated by the time my handler was
called. I then snapped the x, y point, and called setRectangles, and
overwrote the rectangle that was there.

I had some trace statements in the control moved handler, and the
points in the rectangle, and the resulting snap points were correct.

However, what I saw on the screen was not correct. Basically, the
mouse and the rectangle got way out of sync. IE: I started the tracker
at 0, 0, 50, 50. On the first mouse move, the rectangle was 0, 11, 50,
50, and I snapped it to 0, 20, 50, 50. The result was, the rectangle did
not move, it stayed at 0, 0, 50, 50. Not until I moved my mouse down to
about 0, 100 (x, y) did the actual rectangle move vertically down to the
next snap point.

It seemed the rectangle was lagging the mouse by about 100 pixels or
so. I don't mean literally lagging in that it would eventually catch up,
because it wouldn't...I mean it was not being drawing at the snap point
nearest the mouse cursor.

Any ideas?

Thanks,
Joe
Re: Modifying Mouse Points during a Tracker loop [message #449351 is a reply to message #449350] Sun, 23 January 2005 07:16 Go to previous message
Joe Mihalich is currently offline Joe MihalichFriend
Messages: 25
Registered: July 2009
Junior Member
I have a habit of talking to myself in these forums...and sometimes
talking it out helps me think of solutions...which I found one.

It appears that the rectangle recturned from getRectangles() is not
necessarily in sync with the mouse location. I did a
Display.getCurrent().getCursorLocation() in the control moved handler, and
the mouse location was considerably away from the rectangle location.

So, I snapped the rect to the mouse point location, and set that new
rectangle on the tracker, and all seems to be well...on Windows at least.
One doesn't know how something like this will work on linux until you try
it...here's hoping.

Any comments on this solution as to whether I'm still missing the boat?

Thanks,
Joe
Previous Topic:TableEditor Question/Proglem
Next Topic:[ANN] Eclipse GCJ Builder 1.0.6
Goto Forum:
  


Current Time: Mon Nov 18 13:49:54 GMT 2019

Powered by FUDForum. Page generated in 0.01532 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top