From b8dda875a8c57a76f2c7cad07542d018c0546964 Mon Sep 17 00:00:00 2001 From: kosay Date: Sun, 25 Jun 2023 16:18:05 +0900 Subject: [PATCH] feat(ui): Activate the clicked widget and process the click event on the activated widget. --- src/ui/tab.rs | 5 ++-- src/ui/widget/complex/multiple_select.rs | 30 ++++++++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/ui/tab.rs b/src/ui/tab.rs index 7437fff0..c80e4122 100644 --- a/src/ui/tab.rs +++ b/src/ui/tab.rs @@ -185,13 +185,12 @@ impl<'a> Tab<'a> { MouseEventKind::Down(MouseButton::Left) => { if id != active_widget_id { self.activate_widget_by_id(&id); - - return EventResult::Ignore; } } - _ => { + MouseEventKind::Moved => { self.mouse_over_widget_index = Some(index); } + _ => {} } self.active_widget_mut().on_mouse_event(ev) diff --git a/src/ui/widget/complex/multiple_select.rs b/src/ui/widget/complex/multiple_select.rs index e4b648c8..1b891310 100644 --- a/src/ui/widget/complex/multiple_select.rs +++ b/src/ui/widget/complex/multiple_select.rs @@ -476,24 +476,30 @@ impl<'a> SelectForm<'a> { let (chunks, _) = self.chunks_and_arrow(); if chunks[0].contains_point(pos) { - if let MouseEventKind::Down(MouseButton::Left) = ev.kind { - if self.active_form_index != LIST_FORM_ID { - self.activate_form_by_index(LIST_FORM_ID); - return EventResult::Ignore; + match ev.kind { + MouseEventKind::Down(MouseButton::Left) => { + if self.active_form_index != LIST_FORM_ID { + self.activate_form_by_index(LIST_FORM_ID); + } + } + MouseEventKind::Moved => { + self.mouse_over_widget_index = Some(LIST_FORM_ID); } - } else { - self.mouse_over_widget_index = Some(LIST_FORM_ID); + _ => {} } self.active_form_mut().on_mouse_event(ev) } else if chunks[2].contains_point(pos) { - if let MouseEventKind::Down(MouseButton::Left) = ev.kind { - if self.active_form_index != SELECTED_FORM_ID { - self.activate_form_by_index(SELECTED_FORM_ID); - return EventResult::Ignore; + match ev.kind { + MouseEventKind::Down(MouseButton::Left) => { + if self.active_form_index != SELECTED_FORM_ID { + self.activate_form_by_index(SELECTED_FORM_ID); + } + } + MouseEventKind::Moved => { + self.mouse_over_widget_index = Some(SELECTED_FORM_ID); } - } else { - self.mouse_over_widget_index = Some(SELECTED_FORM_ID); + _ => {} } self.active_form_mut().on_mouse_event(ev)