30 lines
843 B
Rust
30 lines
843 B
Rust
use iris::prelude::*;
|
|
|
|
pub(crate) fn on_tap<Rsc: HasEvents>(
|
|
rsc: &mut Rsc,
|
|
ptr: WeakWidget<WidgetPtr>,
|
|
list: WeakWidget<LazySpan>,
|
|
f: impl Fn(&mut Rsc) + 'static,
|
|
) where
|
|
Rsc::State: FocusHost + OpenUrl,
|
|
{
|
|
ptr.on(CursorSense::drag_senses(), move |ctx, rsc: &mut Rsc| {
|
|
let input = &ctx.data;
|
|
let outcome = rsc
|
|
.with_nearest_controller::<SelectionController, _>(list, |id, selection, rsc| {
|
|
selection.drag(id, rsc, input)
|
|
})
|
|
.unwrap_or(SelectionInput::Tapped);
|
|
if outcome == SelectionInput::Tapped {
|
|
f(rsc);
|
|
}
|
|
})
|
|
.add(rsc);
|
|
}
|
|
|
|
pub(crate) fn hold_edge(rsc: &mut impl UiRsc, list: WeakWidget<LazySpan>, key: RowKey) {
|
|
if let Some((top, _bottom)) = list(rsc).extent(key) {
|
|
list(rsc).note_tap(top);
|
|
}
|
|
}
|