Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Setting Cursor Position in TextEditor
Setting Cursor Position in TextEditor [message #482510] Wed, 26 August 2009 20:29 Go to next message
Seth is currently offline Seth
Messages: 10
Registered: July 2009
Junior Member
I would like to set the cursor position in a class which extends
TextEditor.
This is how i tried to do this:
public void setOffset(int offset) {

setHighlightRange(offset,0,true);
}

I thought that eclipse that a highlight length of '0' would simply be
considered a cursor movement. Sometimes it works, but at other times it
doesn't. If i cincrease the length (middle arg), it also only works
sometimes. At other times, the cursor will not move. Looking at the code
of the setHighlightRange, it appears to call

fSourceViewer.setVisibleRegion(offset, length)

where fSourceView is an ISourceViewer. Setting the visible region does not
appear to be what i want....
Any ideas.
Thanks!
Re: Setting Cursor Position in TextEditor [message #482655 is a reply to message #482510] Thu, 27 August 2009 12:51 Go to previous message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Seth wrote:
> I would like to set the cursor position in a class which extends
> TextEditor.
See: org.eclipse.ui.texteditor.ITextEditor.selectAndReveal(int, int).

Dani
> This is how i tried to do this:
> public void setOffset(int offset) {
> setHighlightRange(offset,0,true);
> }
>
> I thought that eclipse that a highlight length of '0' would simply be
> considered a cursor movement.Sometimes it works, but at other times it
> doesn't. If i cincrease the length (middle arg), it also only works
> sometimes. At other times, the cursor will not move. Looking at the
> code of the setHighlightRange, it appears to call
>
> fSourceViewer.setVisibleRegion(offset, length)
>
> where fSourceView is an ISourceViewer. Setting the visible region does
> not appear to be what i want....
> Any ideas.
> Thanks!
>
>
Previous Topic:Multiple Key Bindings to Single Action
Next Topic:TimeZone.getDefault() returns GMT
Goto Forum:
  


Current Time: Fri Oct 31 05:46:51 GMT 2014

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

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