Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 13:53 Go to next message
Geejay is currently offline GeejayFriend
Messages: 160
Registered: February 2010
Senior Member
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] Fri, 16 April 2010 03:02 Go to previous message
Praveen  is currently offline Praveen Friend
Messages: 86
Registered: July 2009
Member
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: Mon Aug 19 22:55:08 GMT 2019

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

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

Back to the top