Skip to content

ui::Inline

Header: winui/ui/text/Inlines.hpp.

One run of inline text with its own formatting. Every formatting field left at its default inherits the containing block's.

An inline with on_click or navigate_uri is a link. It is underlined and drawn in the theme's link colors. A press and release on it calls on_click, then opens navigate_uri. Inlines go to TextControl::set_inlines() or ui::Text::inlines, or into a Paragraph for RichText.

Example:

window.set_content(ui::Text{
    .inlines = {
        {.text = "Text can be "},
        {.text = "bold", .weight = ui::FontWeight::Bold},
        {.text = ", "},
        {.text = "underlined", .underline = true},
        ui::line_break(),
        {.text = "or a link", .on_click = [] { std::println("clicked"); }, .navigate_uri = "https://example.com/"},
    },
});

text

std::string text

The run's text (UTF-8). \n is a line break.

font_family

std::optional<std::string> font_family {}

The font family; unset inherits.

font_size

OptionalFloat font_size {}

The font size in DIPs; unset inherits.

weight

std::optional<FontWeight> weight {}

The font weight; unset inherits.

italic

bool italic = false

Italic. Only switches italic on; an italic block stays italic.

underline

bool underline = false

Underlined.

strikethrough

bool strikethrough = false

Struck through.

color

std::optional<Color> color {}

The text color; unset inherits.

on_click

std::function<void()> on_click {}

Makes the inline a link that calls this when clicked. It is a std::function because inlines are brace-initialized in vectors, which copy them (see spec/Common.hpp's handler note).

std::string navigate_uri {}

Makes the inline a link that opens navigate_uri in its default app when clicked, after on_click.

bool is_link() const

Whether this inline is a link, which means it has on_click or a navigate_uri.