Skip to content

TouchArea

Drew Chase (Home) edited this page Mar 27, 2026 · 1 revision

TouchArea

An invisible hit-testing region that detects clicks, hovers, and drags. Lives in aurora_widgets::interactables::touch_area. Wraps a child widget and adds interaction callbacks without changing its appearance.

Use TouchArea when you need click/hover behavior on a custom widget that isn't a Button.

Quick Start

use aurora_ui::prelude::*;

TouchArea::new()
    .child(Text::new("Click me"))
    .hover_cursor(CursorIcon::Pointer)
    .on_click(|event| println!("Clicked at {:?}", event.position))
    .on_hover(|_rect, hovering| println!("Hover: {hovering}"))

Builder Methods

Method Type Description
child(impl Widget) Box<dyn Widget> The widget to wrap
width(f32) f32 Fixed width (overrides child's natural size)
height(f32) f32 Fixed height
hover_cursor(CursorIcon) CursorIcon Cursor icon when hovering
on_click(FnMut(&MouseClickEvent)) callback Fires on mouse release inside bounds
on_hover(FnMut(Rect, bool)) callback (bounds, is_hovered) — fires on enter/leave
on_mouse_down(FnMut(MouseButton)) callback Fires immediately on mouse press
on_drag(FnMut(Point)) callback Fires on mouse move while pressed

Example

use aurora_ui::prelude::*;

// Custom interactive card
TouchArea::new()
    .child(
        BoxWidget::new()
            .width(200)
            .height(100)
            .background_color(Color::from_hex(0x334155, false))
            .corners(Corners::all(8.0))
            .child(Text::new("Drag me"))
    )
    .hover_cursor(CursorIcon::Grab)
    .on_drag(|pos| println!("Dragging at {pos:?}"))
    .on_click(|_| println!("Released"))

AuroraUI is a cross-platform desktop UI framework that treats performance as a first-class constraint — not an afterthought.

Platform

  • App - Application builder, windowing, and event loop
  • MultiWindow - Window spawning, modals, messaging
  • Native Menu - OS menu bars (menu feature)
  • System Tray - System tray icons (tray feature)
  • Threading - Background tasks, thread-safe state

Core

  • Color - Color utilities and color schemes
  • Undo / Redo - UndoStack and text input undo

Geometry

  • Rect - Rectangle geometry
  • Point - Point geometry
  • Size - Size geometry
  • Edges - Edge insets (padding, margins, borders)
  • Corners - Corner radii for rounded rectangles

GPU

  • GpuContext - GPU surface abstraction and backends

Render

Text

Widgets

  • Layout - Column, Row, Stack, Positioned
  • ScrollView - Scrollable viewport with scrollbar
  • VirtualList - Virtualized list for large datasets
  • Button - Styled button with any child content
  • BoxWidget - Colored rectangle container
  • TextInput - Single-line text input
  • TouchArea - Invisible hit-testing region
  • Drag & Drop - Draggable sources and drop zones
  • ContentSwitch - Conditional child display
  • Image - Raster image display (PNG, JPEG)
  • Composite - Stateful composites & #[composite_widget]
  • TreeView - Hierarchical data with expand/collapse

Components

  • Display - Badge, Card, Alert, Progress, Spinner, Kbd, and more
  • Stepper - Step-by-step progress indicator
  • Forms - Checkbox, Switch, Slider, RadioGroup, Tabs, Accordion, and more
  • SegmentedControl - iOS-style segmented toggle bar
  • NumberInput - Numeric input with +/- buttons
  • RichTextEditor - Rich text editing with bold/italic/underline
  • Form Validation - Validators, error states, form-level validation
  • Overlays - Tooltip, Popover, Dialog, DropdownMenu, Select, Toast
  • Sheet - Slide-in panel from screen edge
  • TagInput - Multi-value input with removable tags
  • SplitPane - Resizable split view with drag handle
  • ColorPicker - Color selection with hex/RGB
  • TimePicker - Time selection with hour/minute spinners
  • DateRangePicker - Dual-calendar date range selection
  • DateTimePicker - Combined date and time selection
  • Data & Advanced - Table, Calendar, Combobox, Command, and more

Theme

  • Theme - Color profiles, slots, and runtime switching

Animation

  • Animation - Tweens, easing, keyframes, timelines, and presets

Code

  • Syntax - Syntax highlighting for 16+ languages

Accessibility

Internationalization

  • i18n - Locale detection, message formatting, RTL layout

Integrations

  • Iconify - Compile-time icons from iconify.design
  • Fonts - Compile-time Google Fonts embedding

Clone this wiki locally