Page 1 of 1

set offset always at the same position

Posted: Fri Jan 13, 2023 1:19 pm
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.

Re: set offset always at the same position

Posted: Fri Jan 13, 2023 2:27 pm
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

Re: set offset always at the same position

Posted: Fri Jan 13, 2023 4:14 pm
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.

Re: set offset always at the same position

Posted: Mon Jan 16, 2023 1:18 pm
by shikhar_472
Hi Team,

Is there any update on this.

Thanks,
Shikhar.

Re: set offset always at the same position

Posted: Mon Jan 16, 2023 1:56 pm
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