Module: ui.widgets.button

Source: ./ui/widgets/button.reef


Overview

ui/widgets/button.reef - Clickable button widget Part of reef-stdlib UI module

The Button widget provides an interactive button that responds to mouse clicks and keyboard activation. It supports:

  • Text labels
  • Multiple visual states (normal, hovered, pressed, disabled)
  • Focus handling
  • Themed appearance

Button generates action events when clicked or activated via keyboard.


Types

ButtonState (enum)

Variants:

  • Normal
  • Hovered
  • Pressed
  • Disabled

ButtonEventResultKind (enum)

Variants:

  • Ignored
  • Handled
  • Clicked
  • RequestFocus

ButtonEventResult

Fields:

Name Type
kind ButtonEventResultKind
button Button

Objects

Button

Extends: widget.Widget

Fields:

Name Type
label string
state ButtonState
focused bool
min_width float
padding_h float
padding_v float

proc init(id: widget.WidgetId, label: string)

Methods:

override shared fn kind(): string

override exclusive proc paint(surf: surface.Surface, th: theme.Theme)


Functions

fn button_state_normal(): ButtonState

fn button_state_hovered(): ButtonState

fn button_state_pressed(): ButtonState

fn button_state_disabled(): ButtonState

fn is_button_normal(s: ButtonState): bool

fn is_button_hovered(s: ButtonState): bool

fn is_button_pressed(s: ButtonState): bool

fn is_button_disabled(s: ButtonState): bool

fn button(label: string): Button

fn button_with_id(label: string, id: int): Button

fn button_label(b: Button): string

fn button_get_state(b: Button): ButtonState

fn button_is_focused(b: Button): bool

fn button_set_label(b: Button, label: string): Button

fn button_set_enabled(b: Button, enabled: bool): Button

fn button_set_min_width(b: Button, width: float): Button

fn button_set_padding(b: Button, horizontal: float, vertical: float): Button

fn button_with_state(b: Button, state: ButtonState): Button

fn button_with_focus(b: Button, focused: bool): Button

fn button_get_id(b: Button): widget.WidgetId

fn button_get_widget_state(b: Button): widget.WidgetState

fn button_get_bounds(b: Button): core.Rect

fn button_preferred_size(b: Button, th: theme.Theme): core.Size

fn button_layout(b: Button, constraints: layout.Constraints, th: theme.Theme): Button

fn button_handle_event(b: Button, e: event.Event): ButtonEventResult

fn dummy_button(): Button

fn button_result_ignored(): ButtonEventResult

fn button_result_handled(): ButtonEventResult

fn button_result_clicked(): ButtonEventResult

fn button_result_focus(b: Button): ButtonEventResult

fn is_button_clicked(r: ButtonEventResult): bool

fn button_result_to_widget_result(r: ButtonEventResult): widget.EventResult

fn handle_mouse_event(b: Button, me: event.MouseEvent, bounds: core.Rect): ButtonEventResult

fn handle_key_event(b: Button, ke: event.KeyEvent): ButtonEventResult

fn handle_focus_event(b: Button, fe: event.FocusEvent): ButtonEventResult

fn get_button_background(state: ButtonState, colors: theme.ThemeColors): core.Color

fn get_button_text_color(state: ButtonState, colors: theme.ThemeColors): core.Color

fn get_button_border_color(state: ButtonState, colors: theme.ThemeColors): core.Color

fn point_in_rect(px: float, py: float, r: core.Rect): bool

fn string_length(s: string): int

fn keys_equal(a: event.KeyCode, b: event.KeyCode): bool


Procedures

proc button_paint(b: Button, surf: surface.Surface, th: theme.Theme)

proc draw_rect_border(surf: surface.Surface, x: float, y: float, w: float, h: float, color: core.Color, width: float)


Generated by reefc doc