sense specific buttons
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
pub trait Sensable<W, Ctx, Tag> {
|
||||
fn on(self, sense: Senses, f: impl SenseFn<Ctx>) -> impl WidgetIdFn<W, Ctx>;
|
||||
fn on(self, sense: impl Into<Senses>, f: impl SenseFn<Ctx>) -> impl WidgetIdFn<W, Ctx>;
|
||||
fn id_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
senses: impl Into<Senses>,
|
||||
f: impl FnMut(&WidgetId<W>, &mut Ctx, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W, Ctx>
|
||||
where
|
||||
W: Widget;
|
||||
fn edit_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
senses: impl Into<Senses>,
|
||||
f: impl FnMut(&mut W, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W, Ctx>
|
||||
where
|
||||
@@ -20,13 +20,17 @@ pub trait Sensable<W, Ctx, Tag> {
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Ctx, Tag>, Ctx, Tag> Sensable<W::Widget, Ctx, Tag> for W {
|
||||
fn on(self, senses: Senses, f: impl SenseFn<Ctx>) -> impl WidgetIdFn<W::Widget, Ctx> {
|
||||
fn on(
|
||||
self,
|
||||
senses: impl Into<Senses>,
|
||||
f: impl SenseFn<Ctx>,
|
||||
) -> impl WidgetIdFn<W::Widget, Ctx> {
|
||||
move |ui| {
|
||||
let id = self.add(ui);
|
||||
ui.add_sensor(
|
||||
&id,
|
||||
Sensor {
|
||||
senses,
|
||||
senses: senses.into(),
|
||||
f: Box::new(f),
|
||||
},
|
||||
);
|
||||
@@ -35,7 +39,7 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx, Tag> Sensable<W::Widget, Ctx, Tag> for W {
|
||||
}
|
||||
fn id_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
senses: impl Into<Senses>,
|
||||
mut f: impl FnMut(&WidgetId<W::Widget>, &mut Ctx, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W::Widget, Ctx>
|
||||
where
|
||||
@@ -48,7 +52,7 @@ impl<W: WidgetLike<Ctx, Tag>, Ctx, Tag> Sensable<W::Widget, Ctx, Tag> for W {
|
||||
}
|
||||
fn edit_on(
|
||||
self,
|
||||
senses: Senses,
|
||||
senses: impl Into<Senses>,
|
||||
mut f: impl FnMut(&mut W::Widget, SenseCtx) + 'static,
|
||||
) -> impl WidgetIdFn<W::Widget, Ctx>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user