set offset always at the same position

Questions about XML that are not covered by the other forums should go here.
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

set offset always at the same position

Post by shikhar_472 »

Hi Team,

i want to set the cursor always at the same position doesnt matter how many words or extra things got added in between the operation and where cursor has been moved but after giving the pop up of complete operation i want to set it back to the same position where i started.

tried using getting getcaretoffset and setting the same but cursor is moving here and there because words got added in between of the operation so caret information has been changed.

Thanks,
Shikhar.
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: set offset always at the same position

Post by mihaela »

Hello,

Please give us more details about your use case, like:
- What product do you use: Oxygen XML Editor or Oxygen Web Author?
- What operation do you use? It is a custom AuthorOperation?
- Can you share the code that you tried?

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: set offset always at the same position

Post by shikhar_472 »

Hi Mihela,

I am using oxygen web author,

case "start":
startOffset = docModel.getAuthorAccess().getEditorAccess().getCaretOffset();
break;
case "complete":
docModel.getAuthorAccess().getEditorAccess().setCaretPosition(startOffset);
break;
default:
logger.info("invalid actionType== " + actionType);
break;
}

i am using this code for spell check operation and after the spell check complete we want the cursor to set at where it got started.
so at start of the operation i am collecting the info about startoffset and when spellcheck is done for the whole doc we are setting the offset to this position as while running the spellcheck few words got added and offset became change for the position where i started so cursor is getting set to different locaion.

Thanks.

Thanks,
Shikhar.
shikhar_472
Posts: 99
Joined: Fri Jul 01, 2022 12:08 pm

Re: set offset always at the same position

Post by shikhar_472 »

Hi Team,

Is there any update on this.

Thanks,
Shikhar.
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: set offset always at the same position

Post by mihaela »

Hello,

What you can do is to create a position in the document before invoking the operation, using the ro.sync.ecss.extensions.api.AuthorDocumentController.createPositionInContent(int) API and then restore this position setting the caret to position.getOffset().

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply