Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: InlineCssTextArea

[97:7] extends: FxObj

InlineCssTextArea wraps the RichTextFX InlineCssTextArea control, a multi-line text area that lets you apply CSS strings directly to arbitrary character ranges. Each character range carries its own CSS string (e.g., "-fx-fill: red; -fx-font-weight: bold;"), which is applied as inline style when the text is rendered. The class supports the full text-editing lifecycle: content manipulation, caret and selection management, undo/redo, clipboard operations, scroll control, and event callbacks. This class is ideal for a rich-text editor where styling is applied programmatically on the fly and does not need to be declared in a separate CSS file.

CSS Style Classes

Style Class Applied To Description
.styled-text-area The area root Default style class applied to all RichTextFX areas.
.content Inner content region Wraps the scrollable text content.
.paragraph-box Each paragraph row Container for one line or paragraph of text.
.paragraph-text Text flow in a paragraph Holds the individual text segments.
.caret The text insertion caret A thin blinking line indicating the insert position.
.selection Selected text highlight Drawn behind selected character ranges.

CSS Properties -- StyledTextArea (.styled-text-area)

Property Values Default Description
-fx-font <font> null (inherits) Font applied to the entire area when no per-character font is set.
-fx-cursor <cursor> text Mouse cursor shape. RichTextFX defaults this to the text cursor.
-fx-background-color <paint> white Background fill of the content area.
-fx-padding <size> or <t> <r> <b> <l> 0 Interior padding between the border and the text.

CSS Properties -- Caret (.caret)

Property Values Default Description
-rtfx-blink-rate <duration> 500ms Blink period of the caret. Set to 0ms to disable blinking.
-fx-stroke <paint> black Color of the caret line.
-fx-stroke-width <number> 1 Width of the caret line in pixels.

CSS Properties -- Selection (.selection)

Property Values Default Description
-fx-fill <paint> dodgerblue Fill color of the selection highlight rectangle.

CSS Properties -- Region (inherited)

Background fills

Property Values Default Description
-fx-background-color <paint> [, <paint>]* white One or more paint values for background fill layers, rendered back to front.
-fx-background-insets <size> or <t> <r> <b> <l> [, ...]* 0 Insets from the region edges for each background fill layer.
-fx-background-radius <size> [/ <size>]* [, ...]* 0 Corner radii for each background fill layer.

Stroked borders

Property Values Default Description
-fx-border-color <paint> or <t> <r> <b> <l> [, ...]* null Paint colors for the border stroke layers.
-fx-border-insets <size> or <t> <r> <b> <l> [, ...]* null Insets from region edges for each border layer.
-fx-border-radius <size> [, ...]* null Corner radii for border stroke layers.
-fx-border-style <border-style> [, ...]* null Border line style (solid, dotted, dashed) plus line cap/join options per layer.
-fx-border-width <size> or <t> <r> <b> <l> [, ...]* null Thickness of each border stroke layer, per side.

Other Region properties

Property Values Default Description
-fx-padding <size> or <t> <r> <b> <l> 0 Interior padding between the region border and its content.
-fx-min-width <size> -1 Minimum width. -1 uses the computed minimum.
-fx-pref-width <size> -1 Preferred width. -1 uses the computed preferred.
-fx-max-width <size> -1 Maximum width. -1 uses the computed maximum.
-fx-min-height <size> -1 Minimum height. -1 uses the computed minimum.
-fx-pref-height <size> -1 Preferred height. -1 uses the computed preferred.
-fx-max-height <size> -1 Maximum height. -1 uses the computed maximum.

CSS Properties -- Node (inherited)

Property Values Default Description
-fx-blend-mode add | blue | color-burn | color-dodge | darken | difference | exclusion | green | hard-light | lighten | multiply | overlay | red | screen | soft-light | src-atop | src-in | src-out | src-over null Blend mode used when compositing this node with nodes beneath it.
-fx-effect <effect> null A visual effect (e.g. DropShadow, InnerShadow) applied to the rendered node.
-fx-opacity <number> [0.0 - 1.0] 1 Opacity of the node. 0 is fully transparent, 1 is fully opaque.
-fx-rotate <number> 0 Rotation angle in degrees applied around the node's center point.
-fx-scale-x <number> 1 Scale factor along the X axis about the node's center.
-fx-scale-y <number> 1 Scale factor along the Y axis about the node's center.
-fx-translate-x <number> 0 Translation offset along the X axis in pixels.
-fx-translate-y <number> 0 Translation offset along the Y axis in pixels.
visibility visible | hidden | collapse | inherit visible Controls whether the node is rendered and participates in layout.
-fx-managed true | false true When false, the parent layout does not manage this node's position or size.

Methods

  • InlineCssTextArea (Text = null)

    Creates a new InlineCssTextArea with optional initial text.

    • @p Text is a string with the initial text content, or null for an empty area.
  • getText ()

    Returns the full plain text content of the area, without any style information.

    • @r A string with all characters in the document.
  • getTextRange (int Start, int End)

    Returns the plain text in the specified character range.

    • @p Start is an int with the inclusive start index.
    • @p End is an int with the exclusive end index.
    • @r A string with the text in the range [Start, End).
  • setText (string Text)

    Replaces the entire content of the area with the given text.

    • @p Text is a string to set as the new content; pass an empty string to clear.
    • @r this object for chaining
  • appendText (string Text)

    Appends text to the end of the current content.

    • @p Text is a string to append.
    • @r this object for chaining
  • insertText (int Pos, string Text)

    Inserts text at the given character index without removing any existing text.

    • @p Pos is an int with the zero-based index at which to insert.
    • @p Text is a string to insert.
    • @r this object for chaining
  • deleteText (int Start, int End)

    Deletes the characters in the range [Start, End) from the document.

    • @p Start is an int with the inclusive start index.
    • @p End is an int with the exclusive end index.
    • @r this object for chaining
  • replaceText (int Start, int End, string Text)

    Replaces the characters in the range [Start, End) with the given text.

    • @p Start is an int with the inclusive start index.
    • @p End is an int with the exclusive end index.
    • @p Text is a string to insert in place of the deleted range.
    • @r this object for chaining
  • getLength ()

    Returns the total number of characters in the area.

    • @r An int with the document length.
  • getParagraphCount ()

    Returns the number of paragraphs (lines when word wrap is off) in the area.

    • @r An int with the paragraph count.
  • getParagraph (int ParIndex)

    Returns the plain text of the paragraph at the given index.

    • @p ParIndex is an int with the zero-based paragraph index.
    • @r A string with the plain text of that paragraph.
  • getCaretPosition ()

    Returns the current caret position as a zero-based character index.

    • @r An int with the caret position.
  • getSelectedText ()

    Returns the currently selected plain text, or an empty string when nothing is selected.

    • @r A string with the selected text.
  • getSelection ()

    Returns the current selection as a Java IndexRange object accessible via AJI. Call .invoke("getStart") and .invoke("getEnd") on the returned object to read the range.

    • @r An AussomJavaObject wrapping the IndexRange of the current selection.
  • selectRange (int Start, int End)

    Sets the selection to the given range and moves the caret to End.

    • @p Start is an int with the inclusive start of the selection.
    • @p End is an int with the exclusive end of the selection.
    • @r this object for chaining
  • selectAll ()

    Selects all text in the area.

    • @r this object for chaining
  • deselect ()

    Clears the current selection without changing the caret position.

    • @r this object for chaining
  • moveTo (int Pos)

    Moves the caret to the given position without selecting any text.

    • @p Pos is an int with the zero-based target character index.
    • @r this object for chaining
  • moveToStart ()

    Moves the caret to position 0, the beginning of the document.

    • @r this object for chaining
  • moveToEnd ()

    Moves the caret to the end of the document.

    • @r this object for chaining
  • undo ()

    Undoes the last edit operation if undo history is available.

    • @r this object for chaining
  • redo ()

    Redoes the last undone operation if redo history is available.

    • @r this object for chaining
  • cut ()

    Cuts the selected text to the system clipboard and removes it from the area.

    • @r this object for chaining
  • copyToClipboard ()

    Copies the selected text to the system clipboard without modifying the area.

    • @r this object for chaining
  • paste ()

    Pastes text from the system clipboard at the current caret position.

    • @r this object for chaining
  • clear ()

    Clears all text from the area, leaving an empty document.

    • @r this object for chaining
  • setWrapText (bool Wrap)

    Sets whether text wraps at the right edge of the area instead of scrolling horizontally.

    • @p Wrap is a bool with true to enable word wrap.
    • @r this object for chaining
  • setEditable (bool Editable)

    Sets whether the user can edit the area content.

    • @p Editable is a bool with false to make the area read-only.
    • @r this object for chaining
  • setPrefSize (double W, double H)

    Sets the preferred width and height of the area in pixels.

    • @p W is a double with the preferred width.
    • @p H is a double with the preferred height.
    • @r this object for chaining
  • setId (string Id)

    Sets the CSS ID of the area node for scene graph lookup and CSS targeting.

    • @p Id is a string with the ID, used with "#id" in CSS selectors and testfx.lookup.
    • @r this object for chaining
  • setNodeStyle (string Style)

    Applies an inline CSS style string to the entire area node. This sets the JavaFX node's own style, not the per-character RichTextFX style.

    • @p Style is a string with one or more CSS property declarations (e.g., "-fx-background-color: black;").
    • @r this object for chaining
  • getStylesheets ()

    Returns the area's stylesheet list as an AussomJavaObject wrapping an ObservableList. Add CSS file URIs to this list to style the area from an external stylesheet. Example: area.getStylesheets().invoke("add", "path/to/editor.css")

    • @r An AussomJavaObject wrapping the stylesheet ObservableList.
  • setLineNumbers (bool Show)

    Shows or hides a line number gutter to the left of each paragraph. When Show is true, uses LineNumberFactory to generate the gutter nodes.

    • @p Show is a bool with true to display line numbers.
    • @r this object for chaining
  • setContextMenu (object MenuObj)

    Attaches a ContextMenu to the area, replacing the built-in right-click menu.

    • @p MenuObj is a ContextMenu object to attach.
    • @r this object for chaining
  • setMouseOverTextDelay (int Millis)

    Sets the delay in milliseconds before a mouse-over-text event fires. Use this in combination with onMouseOverText to show hover tooltips.

    • @p Millis is an int with the hover delay in milliseconds.
    • @r this object for chaining
  • scrollToPixel (double X, double Y)

    Scrolls the viewport to the given pixel offsets.

    • @p X is a double with the horizontal pixel offset.
    • @p Y is a double with the vertical pixel offset.
    • @r this object for chaining
  • scrollYBy (double Delta)

    Scrolls the viewport vertically by the given pixel delta. Positive values scroll down; negative values scroll up.

    • @p Delta is a double with the number of pixels to scroll.
    • @r this object for chaining
  • scrollXBy (double Delta)

    Scrolls the viewport horizontally by the given pixel delta. Positive values scroll right; negative values scroll left.

    • @p Delta is a double with the number of pixels to scroll.
    • @r this object for chaining
  • scrollToBottom ()

    Scrolls the viewport to the bottom of the content.

    • @r this object for chaining
  • onChange (callback OnChange)

    Registers a callback invoked whenever the plain text content changes. The callback receives a PlainTextChange Java object; call .invoke("getInserted"), .invoke("getRemoved"), and .invoke("getPosition") to read change details.

    • @p OnChange is a callback with signature (Change).
    • @r this object for chaining
  • onCaretChange (callback OnChange)

    Registers a callback invoked whenever the caret position changes. The callback receives (ObservableValue, oldPos, newPos) matching the ChangeListener signature.

    • @p OnChange is a callback with signature (ObservableValue, OldPos, NewPos).
    • @r this object for chaining
  • onSelectionChange (callback OnChange)

    Registers a callback invoked whenever the selection range changes. The callback receives (ObservableValue, oldRange, newRange) matching the ChangeListener signature. Call .invoke("getStart") and .invoke("getEnd") on newRange to read the new selection bounds.

    • @p OnChange is a callback with signature (ObservableValue, OldRange, NewRange).
    • @r this object for chaining
  • onMouseOverText (callback OnHover)

    Registers a callback invoked when the mouse hovers over text for the delay set by setMouseOverTextDelay. The callback receives a MouseOverTextEvent Java object; call .invoke("getCharacterIndex") to get the index of the character under the cursor.

    • @p OnHover is a callback with signature (MouseOverTextEvent).
    • @r this object for chaining
  • setStyle (int From, int To, string CssStyle)

    Applies a CSS string to the character range [From, To), overriding any previously set style for that range. The CSS string uses standard JavaFX text CSS properties such as -fx-fill, -fx-font-weight, -fx-font-style, and -fx-font-size.

    • @p From is an int with the inclusive start index of the range.
    • @p To is an int with the exclusive end index of the range.
    • @p CssStyle is a string with one or more CSS declarations (e.g., "-fx-fill: red;").
    • @r this object for chaining
  • setStyleOfParagraph (int ParIndex, string CssStyle)

    Applies a CSS string to the background of the entire paragraph at the given index.

    • @p ParIndex is an int with the zero-based paragraph index.
    • @p CssStyle is a string with one or more CSS declarations.
    • @r this object for chaining
  • clearStyle (int From, int To)

    Removes all inline style from the character range [From, To), reverting to the default.

    • @p From is an int with the inclusive start index of the range.
    • @p To is an int with the exclusive end index of the range.
    • @r this object for chaining
  • clearStyleOfParagraph (int ParIndex)

    Removes any paragraph-level CSS style from the paragraph at the given index.

    • @p ParIndex is an int with the zero-based paragraph index.
    • @r this object for chaining
  • clearStyles ()

    Removes all inline CSS styles from the entire document.

    • @r this object for chaining