public interface TextSelection.TextSelectionSupport

An interface that can be returned from any Component’s Component#getTextSelectionSupport() method to provide text selection support on that component.

Methods

public abstract TextSelection.Spans getTextSelectionForBounds(TextSelection sel, Rectangle bounds)Gets the spans that should be selected for the given bounds.
public abstract boolean isTextSelectionEnabled(TextSelection sel)Checks if text selection is enabled for this component.
public abstract boolean isTextSelectionTriggerEnabled(TextSelection sel)Checks if this component can be used to trigger a text selection.
public abstract TextSelection.Span triggerSelectionAt(TextSelection sel, int x, int y)Trigger a text selection at a given point.
public abstract String getTextForSpan(TextSelection sel, TextSelection.Span span)Returns the text for a given span.

Method details

getTextSelectionForBounds

public abstract TextSelection.Spans getTextSelectionForBounds(TextSelection sel, Rectangle bounds)
Gets the spans that should be selected for the given bounds.

Parameters

sel TextSelection
The TextSelection instance.
bounds Rectangle
The bounds to check. Relative to #getSelectionRoot()

Returns

Spans of text that should be selected.

isTextSelectionEnabled

public abstract boolean isTextSelectionEnabled(TextSelection sel)
Checks if text selection is enabled for this component.

Parameters

sel TextSelection
The TextSelection instance.

Returns

True if text selection is enabled.

isTextSelectionTriggerEnabled

public abstract boolean isTextSelectionTriggerEnabled(TextSelection sel)
Checks if this component can be used to trigger a text selection. On mobile devices text selection is triggered with a long press over a component.

Parameters

sel TextSelection
The TextSelection instance.

Returns

True if text selection can be triggered on this component.

triggerSelectionAt

public abstract TextSelection.Span triggerSelectionAt(TextSelection sel, int x, int y)
Trigger a text selection at a given point.

Parameters

sel TextSelection
The TextSelection instance
x int
The x coordinate of the event. Relative to #getSelectionRoot()
y int
The y coordinate of the event. Relative to #getSelectionRoot()

Returns

The span that should be selected by a long press at this point.

getTextForSpan

public abstract String getTextForSpan(TextSelection sel, TextSelection.Span span)
Returns the text for a given span.

Parameters

sel TextSelection
The TextSelection instance.
span TextSelection.Span
The span describing the range of text that should be returned.

Returns

The text that is contained.