keep the current cursor's position after an Xml insert.
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
keep the current cursor's position after an Xml insert.
Post by sebastienlavandier »
Hi,
In my application, I can add some swing object to an xml document by drag and drop, by using "AuthorDnDListener", and most specially the function "authorDrop" (which is called when dnd is terminated). In this function, I use the function "AuthorDocumentController.insertXMLFragmentSchemaAware(...)" for add my object to the xml document at the current position by using "editorAccess.getCaretOffset()". That works very well !
But after, when I want to save my object in the xml referencement part, I use again the function "AuthorDocumentController.insertXMLFragmentSchemaAware(...)" with the xml referencement part position. That works too ! But the cursor's position is changed to the screen.
How can I do to keep the position's cursor of the first insert ?
Do you have an idea ?
Thanks in advance.
In my application, I can add some swing object to an xml document by drag and drop, by using "AuthorDnDListener", and most specially the function "authorDrop" (which is called when dnd is terminated). In this function, I use the function "AuthorDocumentController.insertXMLFragmentSchemaAware(...)" for add my object to the xml document at the current position by using "editorAccess.getCaretOffset()". That works very well !
But after, when I want to save my object in the xml referencement part, I use again the function "AuthorDocumentController.insertXMLFragmentSchemaAware(...)" with the xml referencement part position. That works too ! But the cursor's position is changed to the screen.
How can I do to keep the position's cursor of the first insert ?
Do you have an idea ?
Thanks in advance.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: keep the current cursor's position after an Xml insert.
Hi,
Probably before making the second insert you could keep the caret position in a variable and then restore it after the insertion like:
Regards,
Radu
Probably before making the second insert you could keep the caret position in a variable and then restore it after the insertion like:
Code: Select all
int caretOffset = authorAccess.getEditorAccess().getCaretOffset();
//Perform second operation and then:
authorAccess.getEditorAccess().setCaretPosition(caretOffset);
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Re: keep the current cursor's position after an Xml insert.
Post by sebastienlavandier »
Hi Radu,
I tried this, but after the second insert the value of the caret position become false (because an xml fragment was inserted).
I can't use this solution.
Do you have another ?
Thanks.
I tried this, but after the second insert the value of the caret position become false (because an xml fragment was inserted).
I can't use this solution.
Do you have another ?
Thanks.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: keep the current cursor's position after an Xml insert.
Hi Sebastien,
Using the Author API you can also create flexible positions (which are updated when the content changes). Something like this:
Maybe such a workaround will give you better flexibility.
Regards,
Radu
Using the Author API you can also create flexible positions (which are updated when the content changes). Something like this:
Code: Select all
Position position = authAccess.getDocumentController().createPositionInContent(authAccess.getEditorAccess().getCaretOffset());
//Perform operation here
authAccess.getEditorAccess().setCaretPosition(position.getOffset());
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Re: keep the current cursor's position after an Xml insert.
Post by sebastienlavandier »
Hi Radu,
Thanks for you answer.
Now the cursor is at the good position (first insert), but the scroll screen stay to the 2nd insert.
Do you have another idea ? or a solution for the scroll ?
Thanks in advance.
Thanks for you answer.
Now the cursor is at the good position (first insert), but the scroll screen stay to the 2nd insert.
Do you have another idea ? or a solution for the scroll ?
Thanks in advance.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: keep the current cursor's position after an Xml insert.
Hi Sebastien,
Sorry for the delay.
We do not have specific API for scrolling (but maybe we could add some).
But you can use this method
to obtain the swing JPanel on which the Author page is rendered.
The parent of this panel should be a JScrollPane and theoretically you could use its methods to obtain the scroll bounds before the action is performed and to set the same scroll bounds after the action is performed.
Regards,
Radu
Sorry for the delay.
We do not have specific API for scrolling (but maybe we could add some).
But you can use this method
Code: Select all
ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.getAuthorComponent()
The parent of this panel should be a JScrollPane and theoretically you could use its methods to obtain the scroll bounds before the action is performed and to set the same scroll bounds after the action is performed.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Re: keep the current cursor's position after an Xml insert.
Post by sebastienlavandier »
Sorry for the delay
Thank you very much for your help
Bye
Thank you very much for your help
Bye
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: keep the current cursor's position after an Xml insert.
Hi,
Oxygen 14.1 was release and it contains a new method in the API to make a specific area of the Author mode visible. The method you can use is:
Here is the javadoc for this method:
http://www.oxygenxml.com/InstData/Edito ... Rectangle)
To get the rectangle corresponding to a specific offset you can use the following API:
And the javadoc is:
http://www.oxygenxml.com/InstData/Edito ... angle(int)
Best Regards,
Mihaela
Oxygen 14.1 was release and it contains a new method in the API to make a specific area of the Author mode visible. The method you can use is:
Code: Select all
ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.scrollToRectangle(Rectangle)
http://www.oxygenxml.com/InstData/Edito ... Rectangle)
To get the rectangle corresponding to a specific offset you can use the following API:
Code: Select all
ro.sync.exml.workspace.api.editor.page.WSTextBasedEditorPage.modelToViewRectangle(int)
http://www.oxygenxml.com/InstData/Edito ... angle(int)
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service