Skip to main content

Crate cotis_interactivity

Crate cotis_interactivity 

Source
Expand description

Higher-level input handling for Cotis applications.

Render backends expose providers — per-frame raw input state from cotis_utils::interactivity (MouseProvider, SimpleKeyboardProvider, SimpleTextProvider). This crate turns that state into UI-friendly managers that track hover, click edges, key edges, and scroll offsets across frames.

§Typical integration

Hold managers in your application state. Each frame, after layout has run:

  1. Call update(...) on each manager with delta_time (seconds).
  2. Read signals: is_clicked(), is_key_pressed(...), get_position(), etc.

Element-scoped managers additionally need layout bounds from a manager that implements cotis_utils::element_state::ElementBoundingBox (for example cotis-layout’s CotisLayoutManager) and, for scrolling, cotis_utils::element_state::ElementClipInternalSize.

CotisApp has blanket implementations of mouse::ElementCursorState, mouse::FullElementCursorState, and scroll::FullElementScrollState when the renderer implements cotis_utils::interactivity::mouse::MouseProvider and the layout manager implements the required element-state traits.

§Modules

  • mouse — hover hit-testing, click edge detection, per-element click managers.
  • keyboard — key edge detection and text input buffering.
  • scroll — wheel/drag scrolling with optional momentum and clamping.

§Examples

use cotis::cotis_app::CotisApp;
use cotis_interactivity::mouse::{ElementCursorState, MouseButtonElementManager, MouseClickingStrategy};
use cotis_interactivity::keyboard::KeyboardManager;
use cotis_utils::interactivity::mouse::MouseButton;
use cotis_utils::interactivity::keyboard::KeyboardKey;

// Inside your per-frame UI logic:
// let hovered = app.is_hovered(element_id);
// click_manager.update(&app as &dyn FullElementCursorState, dt);
// keyboard_manager.update(app.render_borrow());
// if keyboard_manager.is_key_pressed(KeyboardKey::KeyEscape) { ... }

Modules§

keyboard
Keyboard edge detection and text input buffering.
mouse
Mouse hover hit-testing and click edge detection.
scroll
Wheel and drag scrolling with optional momentum.