Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Simple Example of Drawing Rectangle with Mouse
Simple Example of Drawing Rectangle with Mouse [message #780965] Thu, 19 January 2012 12:54 Go to next message
Paul Morris is currently offline Paul Morris
Messages: 9
Registered: December 2011
Junior Member
I've seen PaintExample under the SWT examples which showcases a lot of cool stuff but the code is quite complex (as would be expected). I'm looking for a simple, stripped-down example of just drawing one rectangle on a screen with the start point of the rectangle being where the mouse down occurred and the rectangle outline following the mouse throughout the drag motion. Same behavior as the rectangle drawing tool in the PaintExample plugin just isolated. Can anyone point me to some code?
Re: Simple Example of Drawing Rectangle with Mouse [message #781240 is a reply to message #780965] Fri, 20 January 2012 21:14 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2151
Registered: July 2009
Senior Member
For this case you could actually just use a Tracker, no drawing required:

- start with the example snippet at
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet23.java
- change the Tracker's creation style from SWT.NONE to SWT.RESIZE
- change the Rectangle that's set on it from (e.x, e.y, 100, 100) to
(e.x, e.y, 0, 0)

HTH,
Grant


On 1/19/2012 7:54 AM, Paul Morris wrote:
> I've seen PaintExample under the SWT examples which showcases a lot of
> cool stuff but the code is quite complex (as would be expected). I'm
> looking for a simple, stripped-down example of just drawing one
> rectangle on a screen with the start point of the rectangle being where
> the mouse down occurred and the rectangle outline following the mouse
> throughout the drag motion. Same behavior as the rectangle drawing tool
> in the PaintExample plugin just isolated. Can anyone point me to some code?
Previous Topic:Canvas overlaying Shell
Next Topic:Menu On Button Click
Goto Forum:
  


Current Time: Tue Sep 30 14:12:09 GMT 2014

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

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