Raw Input
Listener, RawGestureDetector, MouseRegion, and TapRegion with every callback.
Arena-free raw pointer callbacks (no gesture disambiguation).
| Widget | Purpose |
|---|---|
Listener | Raw down/move/up/hover/cancel/signal callbacks |
RawGestureDetector | Custom recognizer factories with hit behavior |
MouseRegion | Enter/exit/hover with cursor and opacity |
TapRegion | Inside/outside tap routing with groups |
TapRegionSurface | Nearest tap-region registry |
TextFieldTapRegion | TapRegion defaulting to the text-field group |
Listener
use incular::prelude::*;
use incular::widgets::HitTestBehavior;
fn main() {
let app = Application::new(|_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
Listener::new(Text::new("Touch me"))
.on_pointer_down(|_| println!("down"))
.on_pointer_up(|_| println!("up"))
.on_pointer_hover(|_| println!("hover"))
.behavior(HitTestBehavior::Opaque),
)
.build()
.into()
})
.expect("valid application");
incular::run(app).expect("run application");
}ListenerCallbacks holds all six Option<Rc<dyn Fn(RawPointerEvent)>>
plus trackpad.
RawGestureDetector
Custom recognizer factories plug in here — see the factory types below; the
runnable Listener program above shows the
retained-detector shape in action.
Custom recognizers implement GestureRecognizer (observe, observe_raw,
dispatch, cancel, dispose, as_any_mut) and are constructed via
GestureRecognizerFactory (create, initialize, type_id) or
GestureRecognizerFactoryWithHandlers::new(constructor, initializer)
(with_initializer for Default types). Mismatched types raise
GestureRecognizerFactoryError { expected, actual }.
MouseRegion
use incular::prelude::*;
fn main() {
let app = Application::new(|_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
MouseRegion::new(Text::new("Hover me"))
.on_enter(|_| println!("enter"))
.on_exit(|_| println!("exit"))
.on_hover(|_| println!("hover")),
)
.build()
.into()
})
.expect("valid application");
incular::run(app).expect("run application");
}Enter waits for the first positioned move before resolving hover; exit clears the retained hover route exactly once.
TapRegion
use incular::prelude::*;
fn main() {
let app = Application::new(|_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
TapRegionSurface::new(
TapRegion::new(Text::new("Tap inside or out"))
.on_tap_inside(|_| println!("inside"))
.on_tap_outside(|_| println!("outside"))
.consume_outside_taps(false),
),
)
.build()
.into()
})
.expect("valid application");
incular::run(app).expect("run application");
}TapRegionGroupId: Named(String) / Numeric(u64) / TextField (default),
with From<&str>, From<String>, From<u64>. TextFieldTapRegion is the
same shape defaulting to the text-field group.
ListenerCallbacks / MouseRegionCallbacks / TapRegionCallbacks bundle the
Option<Rc<dyn Fn…>> callback sets for bulk installation via callbacks(…).
Related: GestureDetector,
Hit Testing.