pink/focus

Types

Focus is the type returned by the focus function

pub type Focus {
  Focus(is_focused: Bool)
}

Constructors

  • Focus(is_focused: Bool)

FocusOptions is the type used by the focus function to configure the focus state.

pub opaque type FocusOptions

Functions

pub fn options() -> FocusOptions

Create a new FocusOptions with the default values.

pub fn set_auto_focus(
  options: FocusOptions,
  auto_focus: Bool,
) -> FocusOptions

Set the auto_focus field on the FocusOptions. Auto focus this component, if there’s no active (focused) component right now

pub fn set_id(options: FocusOptions, id: String) -> FocusOptions

Set the id field on the FocusOptions. Set a component’s focus ID, which can be used to programmatically focus the component. This is useful for large interfaces with many focusable elements, to avoid having to cycle through all of them

pub fn set_is_active(
  options: FocusOptions,
  is_active: Bool,
) -> FocusOptions

Set the is_active field on the FocusOptions. Enable or disable this component’s focus, while still maintaining its position in the list of focusable components. This is useful for inputs that are temporarily disabled

Search Document