⬆️ Use of Dioxus main branch instead of 0.5 release
This commit is contained in:
@@ -14,20 +14,20 @@ pub fn use_long_press(
|
||||
on_long_press: impl FnMut() + 'static,
|
||||
) -> UseLongPress {
|
||||
let on_press = std::rc::Rc::new(RefCell::new(on_press));
|
||||
let on_press_cb = use_callback(move || {
|
||||
let on_press_cb = use_callback(move |_| {
|
||||
let mut on_press = on_press.as_ref().borrow_mut();
|
||||
on_press();
|
||||
});
|
||||
|
||||
let on_long_press = std::rc::Rc::new(RefCell::new(on_long_press));
|
||||
let on_long_press_cb = use_callback(move || {
|
||||
let on_long_press_cb = use_callback(move |_| {
|
||||
let mut on_long_press = on_long_press.as_ref().borrow_mut();
|
||||
on_long_press();
|
||||
});
|
||||
|
||||
let mut timer = use_future(move || async move {
|
||||
task::sleep(duration).await;
|
||||
on_long_press_cb.call();
|
||||
on_long_press_cb.call(());
|
||||
});
|
||||
|
||||
timer.cancel();
|
||||
@@ -39,7 +39,7 @@ pub fn use_long_press(
|
||||
let selection_end_cb = move |_: Event<PlatformEventData>| {
|
||||
if !timer.finished() {
|
||||
timer.cancel();
|
||||
on_press_cb.call();
|
||||
on_press_cb.call(());
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user