View mode: basic / threaded / horizontal-split · Log in · Help
March 04, 2007
Moving a shell with style DWT.NONE
I have a small problem. What I try to do is to move, by holding down the middle mouse button, a shell with the style DWT.NONE, with no borders, by adding a listener to the shell. I managed to do that in java with SWT but no when I try the same code the shell's top left corner always moves to the mouse pointer. The only difference I can see between the DWT and SWT code is in SWT I extended the shell class and made my own class, but now in DWT I just adds a listener to a regular shell. Here is the code for the listener:

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'm quite new do D and DWT, I have been using Java and SWT.
An other question also, D has a garbage collector, do I still need to call dispose methods?
Top | Discussion index | About this forum | D home