A multi-line, scrollable text editor — the note-taking / code surface the single-line UITextInput is not. It owns text editing (caret, selection, scrolling, clipboard, variable line heights) but is deliberately style-agnostic: it carries one opaque Int style word per character and defers all meaning to an optional installed styler (smidr.text.UITextStyler).

  • With no styler it is a plain uniform-format multi-line field (what mobile / plain callers want) — the style words are ignored.
  • Install styler = new smidr.text.UIRichStyler() for WYSIWYG formatting (bold / italic / underline / colour / size / headings / lists). The editor never interprets the bits; the styler turns them into TextFormat runs, list markers, indentation and outline boxes, and decides how style flows across a line break. Markdown import/export lives in smidr.text.UIMarkdown.

Editing: printable input, Enter for newlines, Tab, Backspace/Delete, Left/Right (Ctrl = word jump), Up/Down with a desired column, Home/End (Ctrl = document ends), PageUp/PageDown, Ctrl+A/C/X/V. Word-wrap by default; vertical scroll via wheel, a draggable thumb and drag-to- scroll on mobile. Set readOnly for a selectable-but-immutable viewer. Implements UIStyledText so styling modules can transform its style words without depending on this widget.

Constructor

@:value({ text : "" })new(width:Float, height:Float, text:String = "")

Parameters:

width

layout width (the scrollbar lives inside it)

height

the visible viewport height

text

the initial content

Variables

read onlycaretIndex:Int

The current caret position as a character index into text.

@:value(13)fontSize:Int = 13

Base (unscaled) font size for normal text.

@:value(0)maxLength:Int = 0

Hard character cap (0 = unlimited).

@:value(10)padding:Float = 10

Base (unscaled) inner inset.

@:value("")placeholder:String = ""

Dim hint shown while the field is empty.

@:value(false)readOnly:Bool = false

When true, the caret and editing keys are suppressed (a viewer).

read onlyselectionEnd:Int

Selection end (max of caret/anchor).

read onlyselectionStart:Int

Selection start (min of caret/anchor).

read onlystyledText:String

The text buffer (the UIStyledText accessor; mirrors text).

@:value(null)styler:UITextStyler = null

The installed styling policy, or null for a plain uniform-format field.

@:value("")text:String = ""

The full multi-line content.

typingStyle:Int

Style word applied to newly typed characters (opaque to this widget).

@:value(true)wordWrap:Bool = true

Soft-wrap long lines to the field width (default on); false clips and scrolls the caret.

@:value(null)onCaretMove:() ‑> Void = null

Fired whenever the caret or selection moves (for a line/column or toolbar readout).

@:value(null)onChange:String ‑> Void = null

Fired after every edit with the new text.

Methods

getStyleData():Array<Int>

A copy of the per-character style words, to persist alongside text.

onKeyDown(keyCode:Int, charCode:Int, ctrl:Bool, shift:Bool, alt:Bool):Bool

redo():Void

Re-applies the most recently undone edit (Ctrl+Y / Ctrl+Shift+Z).

setRich(newText:String, styleData:Array<Int>):Void

Loads text and its parallel style words together (restores saved formatting).

styleAt(index:Int):Int

styleParagraphs(map:Int ‑> Int):Void

Applies map to every character in the paragraphs the selection touches (and typingStyle).

styleSelection(map:Int ‑> Int):Void

Applies map to every selected character's style, or to typingStyle when nothing is selected.

undo():Void

Reverts the most recent edit (Ctrl+Z).

Inherited Variables

Defined by UIComponent

@:value(true)enabled:Bool = true

Disabled widgets ignore the pointer and typically render dimmed.

@:value(0)read onlyh:Float = 0

Layout height in UI units.

@:value(MouseCursor.BUTTON)hoverCursor:MouseCursor = MouseCursor.BUTTON

Native cursor while hovering (interactive widgets; null keeps the arrow).

@:value(false)read onlyhovered:Bool = false

true while the cursor is over this widget.

@:value(false)longPressable:Bool = false

Opts a subclass that overrides onRightPress (without setting onRightClick) into long-press-as-right-click on touch. Widgets with onRightClick set are included automatically.

@:value(null)onClick:() ‑> Void = null

Fired on a completed click (press + release on this widget). Requires an interactive widget.

@:value(null)onHover:() ‑> Void = null

Fired when the cursor first enters this widget (hover-driven descriptions/previews). Interactive widgets only.

@:value(null)onRightClick:() ‑> Void = null

Fired on a right mouse press over this widget (context menus). Only interactive widgets receive pointer events, so this never fires on passive widgets like UILabel/UIPanel — attach it to a UIButton (or another interactive widget) instead. On touch, a long-press fires the same path (see UIRoot.longPressMs).

@:value(false)read onlypressed:Bool = false

true while a press that started here is held.

@:value(null)tooltip:String = null

Optional tooltip text (already-localized or a fixed string).

@:value(null)tooltipShortcut:String = null

Optional right-aligned shortcut hint rendered in the tooltip.

@:value(0)read onlyw:Float = 0

Layout width in UI units (independent of DisplayObject's content-derived width).

Inherited Methods

Defined by UIComponent

invalidate():Void

Schedules a repaint for the next frame (cheap; deduplicated).

resize(width:Float, height:Float):Void

Sets the layout size and repaints when it changed.

Parameters:

width

the new layout width in UI units

height

the new layout height in UI units