# `Toddy.Iced.Widget.MouseArea`
[🔗](https://github.com/toddy-ui/toddy-elixir/blob/v0.3.0/lib/toddy/iced/widget/mouse_area.ex#L1)

Mouse area -- captures mouse events on child content.

Wraps child content and emits click events for various mouse buttons,
hover enter/exit, cursor movement, scroll, and double-click events.
Optionally sets the mouse cursor when hovering the area.

## Props

- `cursor` (atom) -- mouse cursor to show on hover. One of: `:pointer`,
  `:grab`, `:grabbing`, `:crosshair`, `:text`, `:move`, `:not_allowed`,
  `:progress`, `:wait`, `:help`, `:cell`, `:copy`, `:alias`, `:no_drop`,
  `:all_scroll`, `:zoom_in`, `:zoom_out`, `:context_menu`,
  `:resizing_horizontally`, `:resizing_vertically`,
  `:resizing_diagonally_up`, `:resizing_diagonally_down`,
  `:resizing_column`, `:resizing_row`.
- `on_right_press` (boolean) -- enable right mouse button press events.
- `on_right_release` (boolean) -- enable right mouse button release events.
- `on_middle_press` (boolean) -- enable middle mouse button press events.
- `on_middle_release` (boolean) -- enable middle mouse button release events.
- `on_double_click` (boolean) -- enable double-click events.
- `on_enter` (boolean) -- enable cursor enter events.
- `on_exit` (boolean) -- enable cursor exit events.
- `on_move` (boolean) -- enable cursor move events.
- `on_scroll` (boolean) -- enable scroll wheel events.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

## Events

Always emitted (unconditional):

- `%Widget{type: :click, id: id}` -- left mouse button pressed.
- `%Widget{type: :click, id: "id:release"}` -- left mouse button released.

Conditional (opt-in via props, delivered as `%MouseArea{}` structs):

- `%MouseArea{type: :middle_press, id: id}` -- middle mouse button pressed.
- `%MouseArea{type: :right_press, id: id}` -- right mouse button pressed.
- `%MouseArea{type: :right_release, id: id}` -- right mouse button released.
- `%MouseArea{type: :middle_release, id: id}` -- middle mouse button released.
- `%MouseArea{type: :double_click, id: id}` -- left mouse button double-clicked.
- `%MouseArea{type: :enter, id: id}` -- cursor entered the area.
- `%MouseArea{type: :exit, id: id}` -- cursor exited the area.
- `%MouseArea{type: :move, id: id, x: x, y: y}` -- cursor moved within the area.
- `%MouseArea{type: :scroll, id: id, delta_x: dx, delta_y: dy}` -- scroll wheel within the area.

# `cursor`

```elixir
@type cursor() ::
  :resizing_row
  | :resizing_column
  | :resizing_diagonally_down
  | :resizing_diagonally_up
  | :resizing_vertically
  | :resizing_horizontally
  | :context_menu
  | :zoom_out
  | :zoom_in
  | :all_scroll
  | :no_drop
  | :alias
  | :copy
  | :cell
  | :help
  | :wait
  | :progress
  | :not_allowed
  | :move
  | :text
  | :crosshair
  | :grabbing
  | :grab
  | :pointer
```

# `option`

```elixir
@type option() ::
  {:cursor, cursor()}
  | {:on_right_press, boolean()}
  | {:on_right_release, boolean()}
  | {:on_middle_press, boolean()}
  | {:on_middle_release, boolean()}
  | {:on_double_click, boolean()}
  | {:on_enter, boolean()}
  | {:on_exit, boolean()}
  | {:on_move, boolean()}
  | {:on_scroll, boolean()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.MouseArea{
  a11y: Toddy.Iced.A11y.t() | nil,
  children: [Toddy.Iced.ui_node() | struct()],
  cursor: cursor() | nil,
  id: String.t(),
  on_double_click: boolean() | nil,
  on_enter: boolean() | nil,
  on_exit: boolean() | nil,
  on_middle_press: boolean() | nil,
  on_middle_release: boolean() | nil,
  on_move: boolean() | nil,
  on_right_press: boolean() | nil,
  on_right_release: boolean() | nil,
  on_scroll: boolean() | nil
}
```

# `a11y`

```elixir
@spec a11y(mouse_area :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
```

Sets accessibility annotations.

# `build`

```elixir
@spec build(mouse_area :: t()) :: Toddy.Iced.ui_node()
```

Converts this mouse area struct to a `ui_node()` map via the `Toddy.Iced.Widget` protocol.

# `cursor`

```elixir
@spec cursor(mouse_area :: t(), cursor :: cursor()) :: t()
```

Sets the mouse cursor shown on hover.

# `extend`

```elixir
@spec extend(mouse_area :: t(), children :: [Toddy.Iced.ui_node() | struct()]) :: t()
```

Appends multiple children to the mouse area.

# `new`

```elixir
@spec new(id :: String.t(), opts :: [option()]) :: t()
```

Creates a new mouse area struct.

# `on_double_click`

```elixir
@spec on_double_click(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables double-click events.

# `on_enter`

```elixir
@spec on_enter(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables cursor enter events.

# `on_exit`

```elixir
@spec on_exit(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables cursor exit events.

# `on_middle_press`

```elixir
@spec on_middle_press(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables middle mouse button press events.

# `on_middle_release`

```elixir
@spec on_middle_release(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables middle mouse button release events.

# `on_move`

```elixir
@spec on_move(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables cursor move events.

# `on_right_press`

```elixir
@spec on_right_press(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables right mouse button press events.

# `on_right_release`

```elixir
@spec on_right_release(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables right mouse button release events.

# `on_scroll`

```elixir
@spec on_scroll(mouse_area :: t(), enabled :: boolean()) :: t()
```

Enables or disables scroll wheel events.

# `push`

```elixir
@spec push(mouse_area :: t(), child :: Toddy.Iced.ui_node() | struct()) :: t()
```

Appends a child to the mouse area.

# `with_options`

```elixir
@spec with_options(mouse_area :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing mouse area struct.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
