See: Description
Interface | Description |
---|---|
CaretMoveHandler |
Handle possible moving of individual carets to new positions or change their selections.
|
Class | Description |
---|---|
CascadingNavigationFilter |
Boilerplate
NavigationFilter , which supports chaining of filters
on an JTextComponent. |
NavigationFilterBypass |
Enhanced FilterBypass which understands multicaret.
|
The Editor Caret SPI contains interface(s) to be implemented by clients in order to manipulate the editor carets.
CaretMoveHandler
allows to implement a transaction that will move individual carets or change their selections.
The following code shows how all carets are moved to the
end of the word they are currently on.
editorCaret.moveCarets((CaretMoveContext context) -> {
for (CaretInfo ci : context.getOriginalCarets()) {
Position pos = target.getDocument().createPosition(Utilities.getWordEnd(target, ci.getDot()));
context.setDot(ci, pos);
}
});
A boilerplate CascadingNavigationFilter is provided to
make implementation of NavigationFilters easier. The boilerplate
remembers the preceding filter and will delegate to it. If you create a subclass, you may call super
methods
moveDot
and setDot
to delegate to that previous filter and ultimately perform the action. Calling
methods of FilterBypass will perform the caret action
directly.
The filter can find out the origin of the movement or
the CaretInfo
for actual caret being moved. The
FilterBypass implementation passed to
NavigationFilter can be downcasted to NavigationFilterBypass,
which provides this extended information.
Use cases are shown in javadoc documentation of particular methods.