Page 1 of 1

Keystroke shortcuts in Author View

Posted: Mon Sep 08, 2014 11:17 pm
by stephen.perkins
Pardon if I was unable to locate this in searching the documentation: Are there keyboard shortcuts for moving to the beginning or end of an element in Author View as there are in Text View? (ctrl+[ / ctrl+]) These and perhaps others would be handy.

Related question: Is my assumption it is possible to create a custom operation to move the cursor to specified point correct? E.g. move to opening tag for parent::note[1].

Re: Keystroke shortcuts in Author View

Posted: Tue Sep 09, 2014 9:49 am
by Radu
Hi Stephen,
Are there keyboard shortcuts for moving to the beginning or end of an element in Author View as there are in Text View? (ctrl+[ / ctrl+]) These and perhaps others would be handy.
The somewhat equivalent actions in the Author view for moving to the beginning of an element would be TAB and SHIFT-TAB.
Related question: Is my assumption it is possible to create a custom operation to move the cursor to specified point correct? E.g. move to opening tag for parent::note[1].
Yes, you have lots of API available so you could also implement this as custom Author operations.
Some sample code:

Code: Select all

 /**
* @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
*/
@Override
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
try {
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(authorAccess.getEditorAccess().getCaretOffset());
//Move after the node.
authorAccess.getEditorAccess().setCaretPosition(nodeAtOffset.getEndOffset() + 1);
//Or move before it
authorAccess.getEditorAccess().setCaretPosition(nodeAtOffset.getStartOffset());
//Or get the parent node
AuthorNode parentNode = nodeAtOffset.getParent();
//and move at the beginning of the parent node
authorAccess.getEditorAccess().setCaretPosition(parentNode.getStartOffset() + 1);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
Regards,
Radu