Raxol.Core.FocusManager.Behaviour behaviour (Raxol v0.3.0)

View Source

Defines the behaviour for focus management services.

Summary

Callbacks

Disables a focusable component.

Enables a previously disabled focusable component.

Moves focus to the next focusable element.

Moves focus to the previous focusable element.

Alias for get_focused_element/0.

Gets the ID of the currently focused element.

Gets the next focusable element after the given one.

Gets the previous focusable element before the given one.

Checks if a component has focus.

Registers a handler function to be called when focus changes. The handler function should accept two arguments: old_focus and new_focus.

Registers a focusable component.

Returns to the previously focused element.

Sets focus to a specific component.

Sets the initial focus to a specific component.

Unregisters a focus change handler function.

Unregisters a focusable component.

Callbacks

disable_component(component_id)

@callback disable_component(component_id :: String.t()) :: :ok

Disables a focusable component.

enable_component(component_id)

@callback enable_component(component_id :: String.t()) :: :ok

Enables a previously disabled focusable component.

focus_next(opts)

@callback focus_next(opts :: Keyword.t()) :: :ok

Moves focus to the next focusable element.

focus_previous(opts)

@callback focus_previous(opts :: Keyword.t()) :: :ok

Moves focus to the previous focusable element.

get_current_focus()

@callback get_current_focus() :: String.t() | nil

Alias for get_focused_element/0.

get_focused_element()

@callback get_focused_element() :: String.t() | nil

Gets the ID of the currently focused element.

get_next_focusable(current_focus_id)

@callback get_next_focusable(current_focus_id :: String.t() | nil) :: String.t() | nil

Gets the next focusable element after the given one.

get_previous_focusable(current_focus_id)

@callback get_previous_focusable(current_focus_id :: String.t() | nil) :: String.t() | nil

Gets the previous focusable element before the given one.

has_focus?(component_id)

@callback has_focus?(component_id :: String.t()) :: boolean()

Checks if a component has focus.

register_focus_change_handler(handler_fun)

@callback register_focus_change_handler(
  handler_fun :: (String.t() | nil, String.t() | nil -> any())
) :: :ok

Registers a handler function to be called when focus changes. The handler function should accept two arguments: old_focus and new_focus.

register_focusable(component_id, tab_index, opts)

@callback register_focusable(
  component_id :: String.t(),
  tab_index :: integer(),
  opts :: Keyword.t()
) :: :ok

Registers a focusable component.

return_to_previous()

@callback return_to_previous() :: :ok

Returns to the previously focused element.

set_focus(component_id)

@callback set_focus(component_id :: String.t()) :: :ok

Sets focus to a specific component.

set_initial_focus(component_id)

@callback set_initial_focus(component_id :: String.t()) :: :ok

Sets the initial focus to a specific component.

unregister_focus_change_handler(handler_fun)

@callback unregister_focus_change_handler(
  handler_fun :: (String.t() | nil, String.t() | nil -> any())
) ::
  :ok

Unregisters a focus change handler function.

unregister_focusable(component_id)

@callback unregister_focusable(component_id :: String.t()) :: :ok

Unregisters a focusable component.