Hi Laurent and Andrew,

Am Sa, den 29.01.2005 schrieb Andrew Douglas Pitonyak um 20:20:
> Laurent Godard wrote:
> 
> > Hi,
> >
> >>>> In a text document, how can i get a XTextCursor at the current 
> >>>> position
> >>>> of the ViewCursor?
> >>>
> >>> viewCursor = document.getCurrentController().getViewCursor()
> >>> textCursor = document.Text.createTextCursor()
> >>>
> >>> //TextCursors include the TextRange service
> >>> viewCursorRange = viewCursor.getEnd()
> >>>
> >>> textCursor.gotoRange( viewCursorRange )
> >>
> > You may try
> > viewCursor = document.getCurrentController().getViewCursor()
> > textCursor = document.Text.createTextCursorByRange(viewCursor)
> >
> > Laurent
> 
> 
> This will work great assuming that there is only one text object in the 
> document :-)
> It might be safer to use:
> 
> viewCursor = document.getCurrentController().getViewCursor()
> textCursor = viewCursor.getText().createTextCursorByRange(viewCursor)

Okay, this does the trick. Very nice and short!

I'm sure the day will come when I get all this cursors and text ranges
and stuff just like that, until then I'll try to do my best ... ;)

> But most people simply use the original code, which almost always works :-)

I like solutions that always work. :)

Thank you all,
Marc



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to