Improve Picker to have on_mouse_click_out to dissmis.

This commit is contained in:
Jason Lee 2024-06-27 19:33:24 +08:00
parent f50d4b351c
commit 5590416c4b
2 changed files with 4 additions and 10 deletions

View file

@ -216,16 +216,7 @@ impl Render for PickerStory {
.flex_col() .flex_col()
.items_center() .items_center()
.track_focus(&self.picker.focus_handle(cx)) .track_focus(&self.picker.focus_handle(cx))
.child( .child(h_flex().w(px(450.)).occlude().child(self.picker.clone())),
h_flex()
.w(px(450.))
.occlude()
.child(self.picker.clone())
.on_mouse_down_out(cx.listener(|this, _, cx| {
this.open = false;
cx.notify();
})),
),
), ),
) )
}) })

View file

@ -524,5 +524,8 @@ impl<D: PickerDelegate> Render for Picker<D> {
.child("No matched."), .child("No matched."),
) )
}) })
.on_mouse_down_out(cx.listener(|_, _, cx| {
cx.dispatch_action(Box::new(Cancel));
}))
} }
} }