|
Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
|
Русская версия · Basic controls · Text and state
Use ui::label for a one-line caption or changing status. It displays text and does not accept activation; use a button for an action and a line editor for input.
This larger checkbox example updates the Label named status after each user change. Space or Enter changes the checkbox; F10 or Ctrl+C exits. The standard runner reports errors and restores the terminal.
Build portals_docs_check_change with PORTALS_BUILD_TESTS=ON and run the resulting executable in a terminal. See build setup and installed package setup.
ui::label("Ready") copies the caption; ui::label(status, "Ready") publishes an observing ui::Ref<Label> after successful mount. Set status.text() = "Saved" between frames to change it through the scene's diagnostic boundary. A label may also observe managed string state or a text source; text references describe supported operations. The scene owns the widget; a Ref does not extend its lifetime. Labels are not focus stops by default and have no activation, keyboard or mouse action of their own.
Scene resources support Label#status { "Ready" }; scene.get<Label>("status") observes the loaded label. See scene resources for both formats and text resolution.
The natural selector is Label. It paints normal, focused and disabled styles, with disabled first; ordinary labels do not receive focus by default. It does not paint selected, header or caret. Caption and allocated background use the same resolved style; there are no label-specific PSS glyph properties.
| Property | Values and effect |
|---|---|
| foreground, background | #RRGGBB; foreground and fill |
| bold, italic, underline | true or false; explicit false overrides a lower layer |
| width, height | Nonnegative cells, auto, fit-content, flex(positive weight) in runtime PSS |
| min-width, max-width, min-height, max-height | Nonnegative cell bounds; only min-width also works in compile-time PSS |
Size declarations cannot depend on a state or :read-only; conflicting bounds reject the update and retain the last valid style and geometry. See layout. Manual ControlStyle uses terminal-default colors, normal text, bold focus and italic disabled text. Theme and PSS rules override individual fields; unspecified fields retain lower-layer values. See the cascade.
See portals::Label, portals::ControlStyle, portals::ui::label and portals::ui::Ref for signatures and basic controls for shared behavior.