Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to position the caret from mouse cursor in SWT Text
How to position the caret from mouse cursor in SWT Text [message #526921] Tue, 13 April 2010 09:53 Go to next message
Eclipse UserFriend
My text widget needs to be able to set the caret position where it is selected.

The Text becomes focused when it is double clicked, and I would like to set the caret according to the position of the mouse.

Is there any way to get the mouse position relative to the text widget? Better yet relative to the caret position in the Text widget?
Re: How to position the caret from mouse cursor in SWT Text [message #527666 is a reply to message #526921] Thu, 15 April 2010 23:02 Go to previous message
Eclipse UserFriend
Geejay wrote:
> Is there any way to get the mouse position relative to the text widget?

You can use such a code snippet for getting the cursor position relative
to your Text widget -

Point cursor = display.getCursorLocation();
cursor = display.map(null, text, cursor);
System.out.println("Text Bounds:"+cursor.x);

HTH.

Regards,
Praveen.
Previous Topic:CTabItem Content Not showing up
Next Topic:browser page loading
Goto Forum:
  


Current Time: Sun Aug 31 12:12:34 EDT 2025

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

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

Back to the top