Skip to content

Commit

Permalink
feat(ui): Activate the clicked widget and process the click event on …
Browse files Browse the repository at this point in the history
…the activated widget.
  • Loading branch information
sarub0b0 committed Jun 25, 2023
1 parent 5d4edba commit b8dda87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/ui/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 18 additions & 12 deletions src/ui/widget/complex/multiple_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b8dda87

Please sign in to comment.