On this page
  1. text
  2. icon
  3. icon_size, icon_above, variant, size, width, height, enabled, id, style, on_click, on_hover, on_unhover, on_press, on_release, on_focus, on_blur
  4. show
  5. shake, hovered, pressed, focused
  6. ours

rmp::ui::Button

struct #include <rmp/ui.h> include/rmp/ui.h:1737
struct Button

A button: text, an icon, or both.

text

rmp::Text text

The label; empty for an icon-only button

icon

Picture icon{}

Shown before the label, or alone

icon_size, icon_above, variant, size, width, height, enabled, id, style, on_click, on_hover, on_unhover, on_press, on_release, on_focus, on_blur

float icon_size = 0
bool icon_above = false
Variant variant = Variant::NORMAL
detail::Sizing size{}
float width = 0
float height = 0
bool enabled = true
std::string id{}
Style style{}
rmp::Callback<> on_click
rmp::Callback<> on_hover
rmp::Callback<> on_unhover
rmp::Callback<> on_press
rmp::Callback<> on_release
rmp::Callback<> on_focus
rmp::Callback<> on_blur

The icon's height in design units; 0 = the label's type size (or the picture's own height when there is no label).

icon_above: True: the icon over the label, as a toolbar tile

variant: As ButtonOptions::style

size: A step or design units, as ButtonOptions::size

width: > 0 = a fixed width; 0 = as the immediate one

height: > 0 = a fixed height

enabled: False = drawn disabled; no press, no change, no focus

id: As ButtonOptions::id: only for two with one label

style: Its own look; see Style

on_click: Clicked: released on it, or Enter or A with the focus

on_hover: The pointer arrived on it

on_unhover: ...and left

on_press: The pointer went down on it

on_release: ...and came up

on_focus: The keyboard or gamepad focus arrived

on_blur: ...and left

show

bool show()

Lays it out here, runs the callbacks of what happened, and says whether it was clicked — if (play.show()) works as well as on_click.

Lays it out here

shake, hovered, pressed, focused

void shake()
bool hovered() const
bool pressed() const
bool focused() const

Shakes it side to side (its style's Motion), plays its shake sound and sends EventKind::SHAKE: "that did not work". Starts at the next show().

shake: Shakes it, as Button::shake() does

hovered: The pointer is on it

pressed: Held down on it

focused: It has the focus

ours

KeptState ours

What it remembers; read it with the methods above