Interface ViewActions<PS,SEG,S>
-
- Type Parameters:
PS
- paragraph style typeSEG
- segment typeS
- segment style type
- All Known Implementing Classes:
CodeArea
,GenericStyledArea
,InlineCssTextArea
,InlineCssTextField
,StyleClassedTextArea
,StyleClassedTextField
,StyledTextArea
,StyledTextField
public interface ViewActions<PS,SEG,S>
Specifies view-related API for aTextEditingArea
-
-
Property Summary
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<Integer>
allParToVisibleParIndex(int allParIndex)
Maps a paragraph index fromTextEditingArea.getParagraphs()
into the index system ofgetVisibleParagraphs()
.BooleanProperty
autoScrollOnDragDesiredProperty()
ObjectProperty<ContextMenu>
contextMenuObjectProperty()
DoubleProperty
contextMenuXOffsetProperty()
DoubleProperty
contextMenuYOffsetProperty()
BooleanProperty
editableProperty()
Var<Double>
estimatedScrollXProperty()
The estimated scrollX value.Var<Double>
estimatedScrollYProperty()
The estimated scrollY value.default int
firstVisibleParToAllParIndex()
Returns the index of the first visible paragraph in the index system ofTextEditingArea.getParagraphs()
.BiConsumer<TextFlow,PS>
getApplyParagraphStyle()
Gets the style applicator.<T extends Node & Caret>
Optional<Bounds>getCaretBoundsOnScreen(T caret)
Using the paragraph index of the "all paragraph" index system, returns the bounds of a caret on the given paragraph orOptional.empty()
if no caret is on that paragraph or the pragraph is not visible.Optional<Bounds>
getCharacterBoundsOnScreen(int from, int to)
Gets the character bounds on screendefault ContextMenu
getContextMenu()
Gets theContextMenu
for the area, which is by default null.default double
getContextMenuXOffset()
Gets the horizontal amount in pixels by which to offset thegetContextMenu()
when it is shown, which has a default value of 2.default double
getContextMenuYOffset()
Gets the vertical amount in pixels by which to offset thegetContextMenu()
when it is shown, which has a default value of 2.default Duration
getMouseOverTextDelay()
Defines how long the mouse has to stay still over the text before aMouseOverTextEvent
of typeMOUSE_OVER_TEXT_BEGIN
is fired on this text area.EventHandler<MouseEvent>
getOnInsideSelectionMousePressReleased()
Gets the value of the property onInsideSelectionMousePressReleased.default Consumer<Point2D>
getOnNewSelectionDrag()
Runs the consumer when the mouse is dragged in this scenario: the user has pressed the mouse over some unselected text, and dragged the mouse to a new location within the area, but has not yet released the mouse.EventHandler<MouseEvent>
getOnNewSelectionDragFinished()
Gets the value of the property onNewSelectionDragFinished.EventHandler<MouseEvent>
getOnOutsideSelectionMousePressed()
Gets the value of the property onOutsideSelectionMousePressed.default Consumer<Point2D>
getOnSelectionDrag()
Runs the consumer when the mouse is dragged in this scenario: the user has selected some text, pressed the mouse on top of the selection, dragged it to a new location within the area, but has not yet released the mouse.EventHandler<MouseEvent>
getOnSelectionDropped()
Gets the value of the property onSelectionDropped.Optional<Bounds>
getParagraphBoundsOnScreen(int paragraphIndex)
Returns the bounds of the paragraph if it is visible orOptional.empty()
if it's not.default IntFunction<? extends Node>
getParagraphGraphicFactory()
Gets the function that maps a line index to a node that is positioned to the left of the first character in a paragraph's text.int
getParagraphLinesCount(int paragraphIndex)
Gets the number of lines a paragraph spans whenisWrapText()
is true, or otherwise returns 1.double
getViewportHeight()
Gets the height of the viewport and ignores the padding values added to the area.Bounds
getVisibleParagraphBoundsOnScreen(int visibleParagraphIndex)
Returns the bounds of the paragraph if it is visible orOptional.empty()
if it's not.LiveList<Paragraph<PS,SEG,S>>
getVisibleParagraphs()
Gets the visible paragraphs, even the ones that are barely displayed.default void
hideContextMenu()
Hides the area's context menu if it is notnull
and it isshowing
.CharacterHit
hit(double x, double y)
Helpful for determining which letter is at point x, y:default boolean
isAutoScrollOnDragDesired()
Indicates whether area should auto scroll towards aMouseEvent.MOUSE_DRAGGED
event.default boolean
isEditable()
Indicates whether this text area can be edited by the user.default boolean
isWrapText()
When a run of text exceeds the width of the text region, then this property indicates whether the text should wrap onto another line.default int
lastVisibleParToAllParIndex()
Returns the index of the last visible paragraph in the index system ofTextEditingArea.getParagraphs()
.void
lineEnd(NavigationActions.SelectionPolicy policy)
Move the caret to the end of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraphint
lineIndex(int paragraphIndex, int columnPosition)
Returns 0 if the given paragraph displays its content across only one line, or returns the index of the line on which the given column position appears if the paragraph spans multiple lines.void
lineStart(NavigationActions.SelectionPolicy policy)
Move the caret to the start of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraphObjectProperty<Duration>
mouseOverTextDelayProperty()
void
nextPage(NavigationActions.SelectionPolicy selectionPolicy)
Moves caret to the next page (i.e.ObjectProperty<EventHandler<MouseEvent>>
onInsideSelectionMousePressReleasedProperty()
ObjectProperty<EventHandler<MouseEvent>>
onNewSelectionDragFinishedProperty()
ObjectProperty<Consumer<Point2D>>
onNewSelectionDragProperty()
ObjectProperty<EventHandler<MouseEvent>>
onOutsideSelectionMousePressedProperty()
ObjectProperty<Consumer<Point2D>>
onSelectionDragProperty()
ObjectProperty<EventHandler<MouseEvent>>
onSelectionDroppedProperty()
ObjectProperty<IntFunction<? extends Node>>
paragraphGraphicFactoryProperty()
void
prevPage(NavigationActions.SelectionPolicy selectionPolicy)
Moves caret to the previous page (i.e.void
requestFollowCaret()
If the caret is not visible within the area's view, the area will scroll so that caret is visible in the next layout pass.default void
selectLine()
Selects the current line of a multi-line paragraph.default void
setAutoScrollOnDragDesired(boolean val)
Sets the value of the property autoScrollOnDragDesired.default void
setContextMenu(ContextMenu menu)
default void
setContextMenuXOffset(double offset)
Sets the value of the property contextMenuXOffset.default void
setContextMenuYOffset(double offset)
Sets the value of the property contextMenuYOffset.default void
setEditable(boolean value)
Sets the value of the property editable.default void
setMouseOverTextDelay(Duration delay)
Sets the value of the property mouseOverTextDelay.void
setOnInsideSelectionMousePressReleased(EventHandler<MouseEvent> handler)
Runs the EventHandler when the mouse is released in this scenario: the user has selected some text and then "clicked" the mouse somewhere in that selection (the use pressed the mouse, did not drag it, and released the mouse).default void
setOnNewSelectionDrag(Consumer<Point2D> consumer)
Sets the value of the property onNewSelectionDrag.void
setOnNewSelectionDragFinished(EventHandler<MouseEvent> handler)
Runs the EventHandler when the mouse is released in this scenario: the user has pressed the mouse over some unselected text, and dragged the mouse to a new location within the area, and released the mouse.void
setOnOutsideSelectionMousePressed(EventHandler<MouseEvent> handler)
Runs the EventHandler when the user pressed the mouse over unselected text within the area.default void
setOnSelectionDrag(Consumer<Point2D> consumer)
Sets the value of the property onSelectionDrag.void
setOnSelectionDropped(EventHandler<MouseEvent> handler)
Runs the EventHandler when the mouse is released in this scenario: the user has selected some text, pressed the mouse on top of the selection, dragged it to a new location within the area, and released the mouse within the area.default void
setParagraphGraphicFactory(IntFunction<? extends Node> factory)
Sets the value of the property paragraphGraphicFactory.default void
setWrapText(boolean value)
Sets the value of the property wrapText.void
showParagraphAtBottom(int paragraphIndex)
Lays out the viewport so that the paragraph is the last line (bottom) displayed in the viewport.void
showParagraphAtTop(int paragraphIndex)
Lays out the viewport so that the paragraph is the first line (top) displayed in the viewport.void
showParagraphInViewport(int paragraphIndex)
Shows the paragraph somewhere in the viewport.void
showParagraphRegion(int paragraphIndex, Bounds region)
Lays out the viewport so that the given bounds (according to the paragraph's coordinate system) within the given paragraph is visible in the viewport.Val<Double>
totalHeightEstimateProperty()
The estimated height of the entire document.Val<Double>
totalWidthEstimateProperty()
The estimated width of the entire document.EventStream<?>
viewportDirtyEvents()
Returns anEventStream
that emits anull
value every time the viewport becomes dirty (e.g.int
visibleParToAllParIndex(int visibleParIndex)
Maps a paragraph index fromgetVisibleParagraphs()
into the index system ofTextEditingArea.getParagraphs()
.BooleanProperty
wrapTextProperty()
-
-
-
Property Detail
-
editable
BooleanProperty editableProperty
- See Also:
isEditable()
,setEditable(boolean)
-
wrapText
BooleanProperty wrapTextProperty
- See Also:
isWrapText()
,setWrapText(boolean)
-
mouseOverTextDelay
ObjectProperty<Duration> mouseOverTextDelayProperty
-
autoScrollOnDragDesired
BooleanProperty autoScrollOnDragDesiredProperty
-
onOutsideSelectionMousePressed
ObjectProperty<EventHandler<MouseEvent>> onOutsideSelectionMousePressedProperty
-
onInsideSelectionMousePressReleased
ObjectProperty<EventHandler<MouseEvent>> onInsideSelectionMousePressReleasedProperty
-
onNewSelectionDrag
ObjectProperty<Consumer<Point2D>> onNewSelectionDragProperty
-
onNewSelectionDragFinished
ObjectProperty<EventHandler<MouseEvent>> onNewSelectionDragFinishedProperty
-
onSelectionDrag
ObjectProperty<Consumer<Point2D>> onSelectionDragProperty
- See Also:
getOnSelectionDrag()
,setOnSelectionDrag(Consumer)
-
onSelectionDropped
ObjectProperty<EventHandler<MouseEvent>> onSelectionDroppedProperty
-
paragraphGraphicFactory
ObjectProperty<IntFunction<? extends Node>> paragraphGraphicFactoryProperty
-
contextMenuObject
ObjectProperty<ContextMenu> contextMenuObjectProperty
-
contextMenuXOffset
DoubleProperty contextMenuXOffsetProperty
-
contextMenuYOffset
DoubleProperty contextMenuYOffsetProperty
-
estimatedScrollX
Var<Double> estimatedScrollXProperty
The estimated scrollX value. This can be set in order to scroll the content. Value is only accurate when area does not wrap lines and uses the same font size throughout the entire area.
-
estimatedScrollY
Var<Double> estimatedScrollYProperty
The estimated scrollY value. This can be set in order to scroll the content. Value is only accurate when area does not wrap lines and uses the same font size throughout the entire area.
-
totalWidthEstimate
Val<Double> totalWidthEstimateProperty
The estimated width of the entire document. Accurate when area does not wrap lines and uses the same font size throughout the entire area. Value is only supposed to be set by the skin, not the user.
-
-
Method Detail
-
isEditable
default boolean isEditable()
Indicates whether this text area can be edited by the user. Note that this property doesn't affect editing through the API.
-
setEditable
default void setEditable(boolean value)
Sets the value of the property editable.- Property description:
-
editableProperty
BooleanProperty editableProperty()
- See Also:
isEditable()
,setEditable(boolean)
-
isWrapText
default boolean isWrapText()
When a run of text exceeds the width of the text region, then this property indicates whether the text should wrap onto another line.
-
setWrapText
default void setWrapText(boolean value)
Sets the value of the property wrapText.- Property description:
-
wrapTextProperty
BooleanProperty wrapTextProperty()
- See Also:
isWrapText()
,setWrapText(boolean)
-
getMouseOverTextDelay
default Duration getMouseOverTextDelay()
Defines how long the mouse has to stay still over the text before aMouseOverTextEvent
of typeMOUSE_OVER_TEXT_BEGIN
is fired on this text area. When set tonull
, noMouseOverTextEvent
s are fired on this text area.Default value is
null
.
-
setMouseOverTextDelay
default void setMouseOverTextDelay(Duration delay)
Sets the value of the property mouseOverTextDelay.- Property description:
-
mouseOverTextDelayProperty
ObjectProperty<Duration> mouseOverTextDelayProperty()
-
isAutoScrollOnDragDesired
default boolean isAutoScrollOnDragDesired()
Indicates whether area should auto scroll towards aMouseEvent.MOUSE_DRAGGED
event. This can be used when additional drag behavior is added on top of the area's default drag behavior and one does not want this auto scroll feature to occur. This flag should be set to the correct value before the end of the process InputMap.
-
setAutoScrollOnDragDesired
default void setAutoScrollOnDragDesired(boolean val)
Sets the value of the property autoScrollOnDragDesired.- Property description:
-
autoScrollOnDragDesiredProperty
BooleanProperty autoScrollOnDragDesiredProperty()
-
setOnOutsideSelectionMousePressed
void setOnOutsideSelectionMousePressed(EventHandler<MouseEvent> handler)
Runs the EventHandler when the user pressed the mouse over unselected text within the area.By default, this will
move the caret
to the position where the mouse was pressed and clear out any selection via the code:
.e -> { CharacterHit hit = hit(e.getX(), e.getY()); moveTo(hit.getInsertionIndex(), SelectionPolicy.CLEAR); }
-
onOutsideSelectionMousePressedProperty
ObjectProperty<EventHandler<MouseEvent>> onOutsideSelectionMousePressedProperty()
-
getOnOutsideSelectionMousePressed
EventHandler<MouseEvent> getOnOutsideSelectionMousePressed()
Gets the value of the property onOutsideSelectionMousePressed.- Property description:
-
setOnInsideSelectionMousePressReleased
void setOnInsideSelectionMousePressReleased(EventHandler<MouseEvent> handler)
Runs the EventHandler when the mouse is released in this scenario: the user has selected some text and then "clicked" the mouse somewhere in that selection (the use pressed the mouse, did not drag it, and released the mouse). Note: this consumer is run onMouseEvent.MOUSE_RELEASED
, notMouseEvent.MOUSE_CLICKED
.By default, this will
move the caret
to the position where the mouse was clicked and clear out any selection via the code:
.e -> { CharacterHit hit = hit(e.getX(), e.getY()); moveTo(hit.getInsertionIndex(), SelectionPolicy.CLEAR); }
-
onInsideSelectionMousePressReleasedProperty
ObjectProperty<EventHandler<MouseEvent>> onInsideSelectionMousePressReleasedProperty()
-
getOnInsideSelectionMousePressReleased
EventHandler<MouseEvent> getOnInsideSelectionMousePressReleased()
Gets the value of the property onInsideSelectionMousePressReleased.- Property description:
-
getOnNewSelectionDrag
default Consumer<Point2D> getOnNewSelectionDrag()
Runs the consumer when the mouse is dragged in this scenario: the user has pressed the mouse over some unselected text, and dragged the mouse to a new location within the area, but has not yet released the mouse. Each time the user drags the mouse without releasing it, this hook's consumer gets called.By default, this will create a new selection or
NavigationActions.SelectionPolicy.ADJUST
the current one to be bigger or smaller via the code:
.e -> { CharacterHit hit = hit(e.getX(), e.getY()); moveTo(hit.getInsertionIndex(), SelectionPolicy.ADJUST); }
-
setOnNewSelectionDrag
default void setOnNewSelectionDrag(Consumer<Point2D> consumer)
Sets the value of the property onNewSelectionDrag.- Property description:
-
onNewSelectionDragProperty
ObjectProperty<Consumer<Point2D>> onNewSelectionDragProperty()
-
setOnNewSelectionDragFinished
void setOnNewSelectionDragFinished(EventHandler<MouseEvent> handler)
Runs the EventHandler when the mouse is released in this scenario: the user has pressed the mouse over some unselected text, and dragged the mouse to a new location within the area, and released the mouse.By default, this will
NavigationActions.SelectionPolicy.ADJUST
the current selection to be bigger or smaller via the code:
.e -> { CharacterHit hit = hit(e.getX(), e.getY()); moveTo(hit.getInsertionIndex(), SelectionPolicy.ADJUST); }
-
onNewSelectionDragFinishedProperty
ObjectProperty<EventHandler<MouseEvent>> onNewSelectionDragFinishedProperty()
-
getOnNewSelectionDragFinished
EventHandler<MouseEvent> getOnNewSelectionDragFinished()
Gets the value of the property onNewSelectionDragFinished.- Property description:
-
getOnSelectionDrag
default Consumer<Point2D> getOnSelectionDrag()
Runs the consumer when the mouse is dragged in this scenario: the user has selected some text, pressed the mouse on top of the selection, dragged it to a new location within the area, but has not yet released the mouse. Each time the user drags the mouse without releasing it, this hook's consumer gets called.By default, this will
displace the caret
to that position within the area via the code:
.p -> { CharacterHit hit = hit(p.getX(), p.getY()); displaceCaret(hit.getInsertionIndex()); }
-
setOnSelectionDrag
default void setOnSelectionDrag(Consumer<Point2D> consumer)
Sets the value of the property onSelectionDrag.- Property description:
-
onSelectionDragProperty
ObjectProperty<Consumer<Point2D>> onSelectionDragProperty()
- See Also:
getOnSelectionDrag()
,setOnSelectionDrag(Consumer)
-
setOnSelectionDropped
void setOnSelectionDropped(EventHandler<MouseEvent> handler)
Runs the EventHandler when the mouse is released in this scenario: the user has selected some text, pressed the mouse on top of the selection, dragged it to a new location within the area, and released the mouse within the area.By default, this will relocate the selected text to the character index where the mouse was released via the code:
.e -> { CharacterHit hit = hit(e.getX(), e.getY()); moveSelectedText(hit.getInsertionIndex()); }
-
onSelectionDroppedProperty
ObjectProperty<EventHandler<MouseEvent>> onSelectionDroppedProperty()
-
getOnSelectionDropped
EventHandler<MouseEvent> getOnSelectionDropped()
Gets the value of the property onSelectionDropped.- Property description:
-
getParagraphGraphicFactory
default IntFunction<? extends Node> getParagraphGraphicFactory()
Gets the function that maps a line index to a node that is positioned to the left of the first character in a paragraph's text. Useful for toggle points or indicating the line's number viaLineNumberFactory
.
-
setParagraphGraphicFactory
default void setParagraphGraphicFactory(IntFunction<? extends Node> factory)
Sets the value of the property paragraphGraphicFactory.- Property description:
-
paragraphGraphicFactoryProperty
ObjectProperty<IntFunction<? extends Node>> paragraphGraphicFactoryProperty()
-
getContextMenu
default ContextMenu getContextMenu()
Gets theContextMenu
for the area, which is by default null.
-
setContextMenu
default void setContextMenu(ContextMenu menu)
-
contextMenuObjectProperty
ObjectProperty<ContextMenu> contextMenuObjectProperty()
-
getContextMenuXOffset
default double getContextMenuXOffset()
Gets the horizontal amount in pixels by which to offset thegetContextMenu()
when it is shown, which has a default value of 2.
-
setContextMenuXOffset
default void setContextMenuXOffset(double offset)
Sets the value of the property contextMenuXOffset.- Property description:
-
contextMenuXOffsetProperty
DoubleProperty contextMenuXOffsetProperty()
-
getContextMenuYOffset
default double getContextMenuYOffset()
Gets the vertical amount in pixels by which to offset thegetContextMenu()
when it is shown, which has a default value of 2.
-
setContextMenuYOffset
default void setContextMenuYOffset(double offset)
Sets the value of the property contextMenuYOffset.- Property description:
-
contextMenuYOffsetProperty
DoubleProperty contextMenuYOffsetProperty()
-
estimatedScrollXProperty
Var<Double> estimatedScrollXProperty()
The estimated scrollX value. This can be set in order to scroll the content. Value is only accurate when area does not wrap lines and uses the same font size throughout the entire area.
-
estimatedScrollYProperty
Var<Double> estimatedScrollYProperty()
The estimated scrollY value. This can be set in order to scroll the content. Value is only accurate when area does not wrap lines and uses the same font size throughout the entire area.
-
totalWidthEstimateProperty
Val<Double> totalWidthEstimateProperty()
The estimated width of the entire document. Accurate when area does not wrap lines and uses the same font size throughout the entire area. Value is only supposed to be set by the skin, not the user.
-
totalHeightEstimateProperty
Val<Double> totalHeightEstimateProperty()
The estimated height of the entire document. Accurate when area does not wrap lines and uses the same font size throughout the entire area. Value is only supposed to be set by the skin, not the user.
-
viewportDirtyEvents
EventStream<?> viewportDirtyEvents()
Returns anEventStream
that emits anull
value every time the viewport becomes dirty (e.g. the viewport's width, height, scaleX, scaleY, estimatedScrollX, or estimatedScrollY values change)
-
getVisibleParagraphs
LiveList<Paragraph<PS,SEG,S>> getVisibleParagraphs()
Gets the visible paragraphs, even the ones that are barely displayed.
-
getApplyParagraphStyle
BiConsumer<TextFlow,PS> getApplyParagraphStyle()
Gets the style applicator.
-
getViewportHeight
double getViewportHeight()
Gets the height of the viewport and ignores the padding values added to the area.
-
allParToVisibleParIndex
Optional<Integer> allParToVisibleParIndex(int allParIndex)
Maps a paragraph index fromTextEditingArea.getParagraphs()
into the index system ofgetVisibleParagraphs()
.
-
visibleParToAllParIndex
int visibleParToAllParIndex(int visibleParIndex)
Maps a paragraph index fromgetVisibleParagraphs()
into the index system ofTextEditingArea.getParagraphs()
.
-
firstVisibleParToAllParIndex
default int firstVisibleParToAllParIndex()
Returns the index of the first visible paragraph in the index system ofTextEditingArea.getParagraphs()
.
-
lastVisibleParToAllParIndex
default int lastVisibleParToAllParIndex()
Returns the index of the last visible paragraph in the index system ofTextEditingArea.getParagraphs()
.
-
hit
CharacterHit hit(double x, double y)
Helpful for determining which letter is at point x, y:StyledTextArea area = // creation code area.addEventHandler(MouseEvent.MOUSE_PRESSED, (MouseEvent e) -> { CharacterHit hit = area.hit(e.getX(), e.getY()); int characterPosition = hit.getInsertionIndex(); // move the caret to that character's position area.moveTo(characterPosition, SelectionPolicy.CLEAR); }
-
lineIndex
int lineIndex(int paragraphIndex, int columnPosition)
Returns 0 if the given paragraph displays its content across only one line, or returns the index of the line on which the given column position appears if the paragraph spans multiple lines.
-
getParagraphLinesCount
int getParagraphLinesCount(int paragraphIndex)
Gets the number of lines a paragraph spans whenisWrapText()
is true, or otherwise returns 1. CAUTION: the underlying TextFlow does not immediately account for changes in the stage's width when the paragraph in question is a multi-line paragraph andtext wrap is on
. After callingWindow.setWidth(double)
, it may take anywhere between 150-300 milliseconds for TextFlow to account for this and return the correct line count for the given paragraph. Otherwise, it may return a skewed number, such as the total number of characters on the line.
-
getCaretBoundsOnScreen
<T extends Node & Caret> Optional<Bounds> getCaretBoundsOnScreen(T caret)
Using the paragraph index of the "all paragraph" index system, returns the bounds of a caret on the given paragraph orOptional.empty()
if no caret is on that paragraph or the pragraph is not visible.
-
getCharacterBoundsOnScreen
Optional<Bounds> getCharacterBoundsOnScreen(int from, int to)
Gets the character bounds on screen- Parameters:
from
- the start positionto
- the end position- Returns:
- the bounds or
Optional.empty()
if line is not visible or the range is only a newline character.
-
getVisibleParagraphBoundsOnScreen
Bounds getVisibleParagraphBoundsOnScreen(int visibleParagraphIndex)
Returns the bounds of the paragraph if it is visible orOptional.empty()
if it's not. The returned bounds object will always be within the bounds of the area. In other words, it takes scrolling into account. Note: the bound's width will always equal the area's width, not necessarily the paragraph's real width (if it's short and doesn't take up all of the area's provided horizontal space or if it's long and spans outside of the area's width).- Parameters:
visibleParagraphIndex
- the index in area's list of visible paragraphs.
-
getParagraphBoundsOnScreen
Optional<Bounds> getParagraphBoundsOnScreen(int paragraphIndex)
Returns the bounds of the paragraph if it is visible orOptional.empty()
if it's not. The returned bounds object will always be within the bounds of the area. In other words, it takes scrolling into account. Note: the bound's width will always equal the area's width, not necessarily the paragraph's real width (if it's short and doesn't take up all of the area's provided horizontal space or if it's long and spans outside of the area's width).- Parameters:
paragraphIndex
- the index in area's list of paragraphs (visible and invisible).
-
showParagraphInViewport
void showParagraphInViewport(int paragraphIndex)
Shows the paragraph somewhere in the viewport. If the line is already visible, no noticeable change occurs. If line is above the current view, it appears at the top of the viewport. If the line is below the current view, it appears at the bottom of the viewport.
-
showParagraphAtTop
void showParagraphAtTop(int paragraphIndex)
Lays out the viewport so that the paragraph is the first line (top) displayed in the viewport. Note: if the given area does not have enough lines that follow the given line to span its entire height, the paragraph may not appear at the very top of the viewport. Instead, it may simply be shown in the viewport. For example, given an unwrapped area whose height could show 10 lines but whose content only has 3 lines, callingshowParagraphAtTop(3)
would be no different thanshowParagraphAtTop(1)
.
-
showParagraphAtBottom
void showParagraphAtBottom(int paragraphIndex)
Lays out the viewport so that the paragraph is the last line (bottom) displayed in the viewport. Note: if the given area does not have enough lines preceding the given line to span its entire height, the paragraph may not appear at the very bottom of the viewport. Instead, it may appear towards the bottom of the viewport with some extra space following it. For example, given an unwrapped area whose height could show 10 lines but whose content only has 7 lines, callingshowParagraphAtBottom(1)
would be no different than callingshowParagraphAtBottom(7)
.
-
showParagraphRegion
void showParagraphRegion(int paragraphIndex, Bounds region)
Lays out the viewport so that the given bounds (according to the paragraph's coordinate system) within the given paragraph is visible in the viewport.
-
requestFollowCaret
void requestFollowCaret()
If the caret is not visible within the area's view, the area will scroll so that caret is visible in the next layout pass. Use this method when you wish to "follow the caret" (i.e. auto-scroll to caret) after making a change (add/remove/modify area's segments).
-
lineStart
void lineStart(NavigationActions.SelectionPolicy policy)
Move the caret to the start of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraph- Parameters:
policy
- useNavigationActions.SelectionPolicy.CLEAR
when no selection is desired anNavigationActions.SelectionPolicy.ADJUST
when a selection from starting point to the place to where the caret is moved is desired.
-
lineEnd
void lineEnd(NavigationActions.SelectionPolicy policy)
Move the caret to the end of either the line in a multi-line wrapped paragraph or the paragraph in a single-line / non-wrapped paragraph- Parameters:
policy
- useNavigationActions.SelectionPolicy.CLEAR
when no selection is desired anNavigationActions.SelectionPolicy.ADJUST
when a selection from starting point to the place to where the caret is moved is desired.
-
selectLine
default void selectLine()
Selects the current line of a multi-line paragraph.
-
prevPage
void prevPage(NavigationActions.SelectionPolicy selectionPolicy)
Moves caret to the previous page (i.e. page up)- Parameters:
selectionPolicy
- useNavigationActions.SelectionPolicy.CLEAR
when no selection is desired andNavigationActions.SelectionPolicy.ADJUST
when a selection from starting point to the place to where the caret is moved is desired.
-
nextPage
void nextPage(NavigationActions.SelectionPolicy selectionPolicy)
Moves caret to the next page (i.e. page down)- Parameters:
selectionPolicy
- useNavigationActions.SelectionPolicy.CLEAR
when no selection is desired andNavigationActions.SelectionPolicy.ADJUST
when a selection from starting point to the place to where the caret is moved is desired.
-
hideContextMenu
default void hideContextMenu()
Hides the area's context menu if it is notnull
and it isshowing
.
-
-