View previous topic :: View next topic |
Author |
Message |
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Sun Mar 11, 2007 9:09 am Post subject: Need help with a listener that moves a shell |
|
|
What I try to do is a listener that moves a shell by holding down the middle mouse button. I want this because I use the style DWT.NONE on the shell. I manged to do this in java and swt but the same code doesn't work as expected in d with dwt.
Code: | private class MouseListenerMiddle : Listener
{
private int startX = 0;
private int startY = 0;
public void handleEvent (Event e)
{
if (e.type == DWT.MouseDown && e.button == 2)
{
startX = e.x;
startY = e.y;
}
if (e.type == DWT.MouseMove && (e.stateMask & DWT.BUTTON2) != 0)
{
Point p = shell.toDisplay(e.x, e.y);
p.x -= startX;
p.y -= startY;
shell.setLocation(p);
}
}
} |
I can describe the problem with an example:
If you have the mouse pointer 100 pixels to the right of the top left corner of a window and moves the window you expect that the mouse pointer always is 100 pixels to the right of the top left corner but now it isn't. The top left corner of the window moves to the mouse pointer all the time. |
|
Back to top |
|
|
WasserDragoon
Joined: 29 Sep 2007 Posts: 23 Location: Germany
|
|
Back to top |
|
|
keinfarbton
Joined: 03 Dec 2005 Posts: 224 Location: Stuttgart - Germany
|
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Mon May 05, 2008 3:31 am Post subject: |
|
|
My post was over a year ago and since that I've seen better ways to do what I wanted to achieve and I have not tried my way again. But thanks for the replies. |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Mon May 05, 2008 3:31 am Post subject: |
|
|
My post was over a year ago and since that I've seen better ways to do what I wanted to achieve and I have not tried my way again. But thanks for the replies. |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Mon May 05, 2008 3:33 am Post subject: |
|
|
Oh sorry for the double post, I got some kind of error |
|
Back to top |
|
|
|