Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class TextInputGeometry
- Object
- TextInputGeometry
Immutable screen geometry for synchronous native keyboard queries. Construct on the EDT;
the native UI thread must never wait for the EDT, which can itself be waiting for drawing.
Coordinates are absolute screen pixels and document offsets are UTF-16 indices.
Input arrays and query results are copied so native readers never share mutable editor geometry.
Nested types
interface TextInputGeometry.Provider | Optional optimized geometry provider for large custom editors. |
Constructors
public TextInputGeometry(int[] carets, int start, int end, int[] selection, int[] fallback) | Each caret record is {UTF-16 offset, x, y, width, height}. |
Methods
public static TextInputGeometry capture(TextInputClient client) | Captures a bounded visible range for clients that do not provide a specialized snapshot. |
public int[] rectForOffset(int offset) | Returns the last captured caret rectangle for an offset, or the active caret offscreen. |
public int offsetAtPoint(int x, int y) | Hit-tests only immutable visible geometry. |
public int[] selectionRects(int a, int b) | Returns exact captured selection geometry for the active range, and visible character rectangles for other native queries without touching a live editor off the EDT. |
Inherited methods
Constructor details
TextInputGeometry
public TextInputGeometry(int[] carets, int start, int end, int[] selection, int[] fallback)Each caret record is {UTF-16 offset, x, y, width, height}. Include visible insertion
positions, in document order, including the endpoint after each visible run. Selection
rectangles use {x, y, width, height} records. All arrays must be non-null; carets and
selection may be empty. The fallback must be the active caret’s {x, y, width, height}.
The start and end offsets describe the captured selection and may be in either order.
Method details
capture
public static TextInputGeometry capture(TextInputClient client)Captures a bounded visible range for clients that do not provide a specialized snapshot.
Large editors can override TextInputGeometry.Provider to walk visual lines once.
rectForOffset
public int[] rectForOffset(int offset)Returns the last captured caret rectangle for an offset, or the active caret offscreen.
offsetAtPoint
public int offsetAtPoint(int x, int y)Hit-tests only immutable visible geometry. Vertical distance takes priority across lines.
selectionRects
public int[] selectionRects(int a, int b)Returns exact captured selection geometry for the active range, and visible character
rectangles for other native queries without touching a live editor off the EDT.