summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-11-12 00:47:21 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-11-12 00:47:21 +0100
commit7ff95f3a884fc5f7ca7417408bd6d4ed47c4e9cc (patch)
treee118cf1c14f221cb95bb8bbd9323c47fd0fa3151 /native
parent31c509b2063907ad4907f248f82724c6fd641032 (diff)
downloadiced-7ff95f3a884fc5f7ca7417408bd6d4ed47c4e9cc.tar.gz
iced-7ff95f3a884fc5f7ca7417408bd6d4ed47c4e9cc.tar.bz2
iced-7ff95f3a884fc5f7ca7417408bd6d4ed47c4e9cc.zip
Implement event capturing for `PickList`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/pick_list.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs
index ee113e5e..113197f7 100644
--- a/native/src/widget/pick_list.rs
+++ b/native/src/widget/pick_list.rs
@@ -230,10 +230,12 @@ where
) -> event::Status {
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
- if *self.is_open {
+ let event_status = if *self.is_open {
// TODO: Encode cursor availability in the type system
*self.is_open =
cursor_position.x < 0.0 || cursor_position.y < 0.0;
+
+ event::Status::Captured
} else if layout.bounds().contains(cursor_position) {
let selected = self.selected.as_ref();
@@ -242,18 +244,24 @@ where
.options
.iter()
.position(|option| Some(option) == selected);
- }
+
+ event::Status::Captured
+ } else {
+ event::Status::Ignored
+ };
if let Some(last_selection) = self.last_selection.take() {
messages.push((self.on_selected)(last_selection));
*self.is_open = false;
+
+ event::Status::Captured
+ } else {
+ event_status
}
}
- _ => {}
+ _ => event::Status::Ignored,
}
-
- event::Status::Ignored
}
fn draw(