1681-engine / ui / RichText
Class: RichText ​
Defined in: src/ui/rich/RichText.ts:23
Text with inline markup — colour, bold, italic, size and icons (see parseRichText) — wrapped to a width and aligned. A Widget, so it stacks and pins like a Label, and a plain Pixi container in the world too.
It does its work only when the text or the layout options change: no per-frame cost. Its runs and icons are kept and reused when the text changes, so a log line rewritten keeps its display objects. Under a pixel-perfect UI root (or with pixelPerfect) every run and icon lands on a whole pixel and icons scale by whole multiples.
Extends ​
Constructors ​
Constructor ​
new RichText(markup, options): RichText;Defined in: src/ui/rich/RichText.ts:33
Parameters ​
| Parameter | Type |
|---|---|
markup | string |
options | RichTextOptions |
Returns ​
RichText
Overrides ​
Properties ​
boxH ​
protected boxH: number = 0;Defined in: src/ui/Widget.ts:23
Inherited from ​
boxW ​
protected boxW: number = 0;Defined in: src/ui/Widget.ts:22
Inherited from ​
focusable ​
focusable: boolean = false;Defined in: src/ui/Widget.ts:21
Whether the focus manager may land on it (buttons, sliders, toggles).
Inherited from ​
Accessors ​
boxHeight ​
Get Signature ​
get boxHeight(): number;Defined in: src/ui/Widget.ts:31
Returns ​
number
Inherited from ​
boxWidth ​
Get Signature ​
get boxWidth(): number;Defined in: src/ui/Widget.ts:27
Returns ​
number
Inherited from ​
enabled ​
Get Signature ​
get enabled(): boolean;Defined in: src/ui/Widget.ts:35
Returns ​
boolean
Set Signature ​
set enabled(v): void;Defined in: src/ui/Widget.ts:39
Parameters ​
| Parameter | Type |
|---|---|
v | boolean |
Returns ​
void
Inherited from ​
focused ​
Get Signature ​
get focused(): boolean;Defined in: src/ui/Widget.ts:47
Returns ​
boolean
Inherited from ​
host ​
Get Signature ​
get protected host(): UiHost | null;Defined in: src/ui/Widget.ts:90
The root it sits under, looked up when needed: a widget may be built before it is added.
Returns ​
UiHost | null
Inherited from ​
layout ​
Get Signature ​
get layout(): RichLayout;Defined in: src/ui/rich/RichText.ts:58
Where every line, run and icon was placed, for hit-testing a word or drawing behind one.
Returns ​
markup ​
Get Signature ​
get markup(): string;Defined in: src/ui/rich/RichText.ts:53
The markup shown.
Returns ​
string
Methods ​
activate() ​
activate(): void;Defined in: src/ui/Widget.ts:82
Accept pressed while focused (Enter, the pad's A).
Returns ​
void
Inherited from ​
canFocus() ​
canFocus(): boolean;Defined in: src/ui/Widget.ts:75
Focusable now: enabled, shown, and every parent shown.
Returns ​
boolean
Inherited from ​
childResized() ​
protected childResized(_child): void;Defined in: src/ui/Widget.ts:108
A child widget's box changed size by itself (a Label given a longer text). A widget that places a child by its size (a Button centring its content) lays it out again here; the default does nothing, so a Stack still waits for its layout() and a change does not ripple up through every container.
Parameters ​
| Parameter | Type |
|---|---|
_child | Widget |
Returns ​
void
Inherited from ​
destroy() ​
destroy(options?): void;Defined in: src/ui/rich/RichText.ts:123
Removes all internal references and listeners as well as removes children from the display list. Do not use a Container after calling destroy.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
options? | DestroyOptions | Options parameter. A boolean will act as if all options have been set to that value |
Returns ​
void
Example ​
container.destroy();
container.destroy(true);
container.destroy({ children: true });
container.destroy({ children: true, texture: true, textureSource: true });Overrides ​
Widget.destroymakeInteractive() ​
protected makeInteractive(): void;Defined in: src/ui/Widget.ts:98
Hit-tested by Pixi, and every press on it is kept from the world. A widget whose drawing has gaps (a scroll view, an empty panel) also sets a hitArea over its box, so a press between its pieces is not the world's.
Returns ​
void
Inherited from ​
navigate() ​
navigate(_dir): boolean;Defined in: src/ui/Widget.ts:85
A direction pressed while focused; true when the widget used it (a slider stepping) so focus stays.
Parameters ​
| Parameter | Type |
|---|---|
_dir | NavDirection |
Returns ​
boolean
Inherited from ​
notifyResized() ​
protected notifyResized(): void;Defined in: src/ui/Widget.ts:111
Tells the parent widget this one's box changed size by itself.
Returns ​
void
Inherited from ​
place() ​
place(x, y): this;Defined in: src/ui/Widget.ts:68
Moves it, on whole pixels under a pixel-perfect root.
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns ​
this
Inherited from ​
redraw() ​
protected redraw(): void;Defined in: src/ui/rich/RichText.ts:128
Draws the current size and state.
Returns ​
void
Overrides ​
relayout() ​
relayout(): void;Defined in: src/ui/rich/RichText.ts:87
Lays out and draws again: after the font's colours or the icons' textures were swapped under it.
Returns ​
void
resize() ​
resize(width, height): this;Defined in: src/ui/Widget.ts:59
Resizes the layout box (whole pixels under a pixel-perfect root) and redraws.
Parameters ​
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns ​
this
Inherited from ​
setAlign() ​
setAlign(align): this;Defined in: src/ui/rich/RichText.ts:79
Parameters ​
| Parameter | Type |
|---|---|
align | RichAlign |
Returns ​
this
setFocused() ​
setFocused(v): void;Defined in: src/ui/Widget.ts:52
Called by the focus manager.
Parameters ​
| Parameter | Type |
|---|---|
v | boolean |
Returns ​
void
Inherited from ​
setText() ​
setText(markup): this;Defined in: src/ui/rich/RichText.ts:63
Changes the text; the same markup again costs nothing.
Parameters ​
| Parameter | Type |
|---|---|
markup | string |
Returns ​
this
setWrapWidth() ​
setWrapWidth(width): this;Defined in: src/ui/rich/RichText.ts:71
Wraps to a new width (undefined: only at \n).
Parameters ​
| Parameter | Type |
|---|---|
width | number | undefined |
Returns ​
this