Node selection listener
Oxygen general issues.
-
- Posts: 35
- Joined: Fri Nov 11, 2011 10:34 am
Node selection listener
Post by maxim.kovalev »
Hi all
Tell me whether there is a listener that is triggered by Oxygen on the node selection?
thanks
Tell me whether there is a listener that is triggered by Oxygen on the node selection?
thanks
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Node selection listener
Hi Maxim,
You can add an AuthorCaretListener to the Author Editor Access and find the selected node when the caret position is updated:
To find if there is a selection in the Author page:
To find the node which is perfectly surrounded by the current selection in the Author editor, you can call the following method (available in Author Editor Access):
This method was introduced in oXygen version 13.1.
For older oXygen versions, here is a sample of how you can get the fully selected node:
This is the link to the online Author SDK Javadoc:
http://www.oxygenxml.com/InstData/Edito ... index.html
Best Regards,
Mihaela
You can add an AuthorCaretListener to the Author Editor Access and find the selected node when the caret position is updated:
Code: Select all
authorAccess.getEditorAccess().addAuthorCaretListener(caretListener);
Code: Select all
boolean hasSelection = authorAccess.getEditorAccess().hasSelection();
Code: Select all
AuthorNode getFullySelectedNode()
For older oXygen versions, here is a sample of how you can get the fully selected node:
Code: Select all
boolean hasSelection = authorAccess.getEditorAccess().hasSelection();
if (hasSelection) {
// Find the selection start offset
int selStart = authorAccess.getEditorAccess().getSelectionStart();
// Find the selection end offset
int selEnd = authorAccess.getEditorAccess().getSelectionEnd();
// Find if an Author node starts at selection start offset
OffsetInformation info = authorAccess.getDocumentController().getContentInformationAtOffset(selStart);
if (info.getPositionType() == OffsetInformation.ON_START_MARKER) {
// Find if an this node ends at selection end offset
if (info.getNodeForMarkerOffset().getEndOffset() == selEnd - 1) {
// This is the the fully selected node
System.out.println("Fully selected node: " + info.getNodeForMarkerOffset().getName());
}
}
}
http://www.oxygenxml.com/InstData/Edito ... index.html
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 35
- Joined: Fri Nov 11, 2011 10:34 am
Re: Node selection listener
Post by maxim.kovalev »
Hi Mihaela
boolean hasSelection = authorAccess.getEditorAccess().hasSelection();
I for some reason always returns false
boolean hasSelection = authorAccess.getEditorAccess().hasSelection();
I for some reason always returns false
-
- Posts: 35
- Joined: Fri Nov 11, 2011 10:34 am
Re: Node selection listener
Post by maxim.kovalev »
boolean hasSelection = authorAccess.getEditorAccess().hasSelection();
only works when you select a node on the top panel, and I wanted to get in contact with the cursor contents
only works when you select a node on the top panel, and I wanted to get in contact with the cursor contents
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Node selection listener
Hi Maxim,
If you just want to find the node at caret position:
Regards,
Mihaela
If you just want to find the node at caret position:
Code: Select all
int caretOffset = authorAccess.getEditorAccess().getCaretOffset();
AuthorNode nodeAtCaret = authorAccess.getDocumentController().
getNodeAtOffset(caretOffset);
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Posts: 35
- Joined: Fri Nov 11, 2011 10:34 am
Re: Node selection listener
Post by maxim.kovalev »
sorry =)
the relevant information can be obtained from
authorAccess.getEditorAccess (). addAuthorCaretListener (caretListener);
AuthorCaretEvent arg0.getNode
большое спасибо =)
the relevant information can be obtained from
authorAccess.getEditorAccess (). addAuthorCaretListener (caretListener);
AuthorCaretEvent arg0.getNode
большое спасибо =)
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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