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 07: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 16:14 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
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: Mon Apr 21 05:56:55 EDT 2014

Powered by FUDForum. Page generated in 0.02017 seconds