diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs index f722167b6f3696deaabcd671ea64d1c0fb908efe..499b3ed99d579af99ec02dddadad9a6aa77dd0d6 100644 --- a/crates/auto_update/src/auto_update.rs +++ b/crates/auto_update/src/auto_update.rs @@ -270,7 +270,7 @@ impl View for AutoUpdateIndicator { ) .boxed() }) - .on_click(|cx| cx.dispatch_action(DismissErrorMessage)) + .on_click(|_, cx| cx.dispatch_action(DismissErrorMessage)) .boxed() } AutoUpdateStatus::Idle => Empty::new().boxed(), diff --git a/crates/chat_panel/src/chat_panel.rs b/crates/chat_panel/src/chat_panel.rs index 415ff6187ec72cca09c04cff901f34c9edadab27..bb835c66401d595607546fbca5453d85461c2164 100644 --- a/crates/chat_panel/src/chat_panel.rs +++ b/crates/chat_panel/src/chat_panel.rs @@ -320,7 +320,7 @@ impl ChatPanel { .boxed() }) .with_cursor_style(CursorStyle::PointingHand) - .on_click(move |cx| { + .on_click(move |_, cx| { let rpc = rpc.clone(); let this = this.clone(); cx.spawn(|mut cx| async move { diff --git a/crates/contacts_panel/src/contacts_panel.rs b/crates/contacts_panel/src/contacts_panel.rs index 45b5f69b5e2efea846b6ae49716777ea9ae0b7a1..171b4194960fc54f7c61b5d50e5e46d2a4b69c81 100644 --- a/crates/contacts_panel/src/contacts_panel.rs +++ b/crates/contacts_panel/src/contacts_panel.rs @@ -204,7 +204,7 @@ impl ContactsPanel { } else { CursorStyle::Arrow }) - .on_click(move |cx| { + .on_click(move |_, cx| { if !is_host && !is_guest { cx.dispatch_global_action(JoinProject { project_id, diff --git a/crates/diagnostics/src/items.rs b/crates/diagnostics/src/items.rs index 39b5437a6a49360250e3ce28d8d4ae1885cfde67..ef99cbf5a87868d54c3c334c2957f8f6f2022d58 100644 --- a/crates/diagnostics/src/items.rs +++ b/crates/diagnostics/src/items.rs @@ -161,7 +161,7 @@ impl View for DiagnosticIndicator { .boxed() }) .with_cursor_style(CursorStyle::PointingHand) - .on_click(|cx| cx.dispatch_action(crate::Deploy)) + .on_click(|_, cx| cx.dispatch_action(crate::Deploy)) .aligned() .boxed(), ); @@ -194,7 +194,7 @@ impl View for DiagnosticIndicator { .boxed() }) .with_cursor_style(CursorStyle::PointingHand) - .on_click(|cx| cx.dispatch_action(GoToNextDiagnostic)) + .on_click(|_, cx| cx.dispatch_action(GoToNextDiagnostic)) .boxed(), ); } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f4453774f7b9ff784d27154bd2db51bced27d888..a04d27a8bb669cc5427562069a9bed444421f591 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1189,7 +1189,7 @@ impl Element for EditorElement { click_count, .. } => self.mouse_down(*position, *alt, *shift, *click_count, layout, paint, cx), - Event::LeftMouseUp { position } => self.mouse_up(*position, cx), + Event::LeftMouseUp { position, .. } => self.mouse_up(*position, cx), Event::LeftMouseDragged { position } => { self.mouse_dragged(*position, layout, paint, cx) } diff --git a/crates/gpui/src/elements/mouse_event_handler.rs b/crates/gpui/src/elements/mouse_event_handler.rs index 12166d45b541b3d9316c372a464b2e121775b4ca..1ee7c6cbb5e57bf2108d36f48424fd3c9db7e058 100644 --- a/crates/gpui/src/elements/mouse_event_handler.rs +++ b/crates/gpui/src/elements/mouse_event_handler.rs @@ -15,7 +15,7 @@ pub struct MouseEventHandler { child: ElementBox, cursor_style: Option, mouse_down_handler: Option>, - click_handler: Option>, + click_handler: Option>, drag_handler: Option>, padding: Padding, } @@ -57,7 +57,7 @@ impl MouseEventHandler { self } - pub fn on_click(mut self, handler: impl FnMut(&mut EventContext) + 'static) -> Self { + pub fn on_click(mut self, handler: impl FnMut(usize, &mut EventContext) + 'static) -> Self { self.click_handler = Some(Box::new(handler)); self } @@ -151,14 +151,18 @@ impl Element for MouseEventHandler { handled_in_child } } - Event::LeftMouseUp { position, .. } => { + Event::LeftMouseUp { + position, + click_count, + .. + } => { state.prev_drag_position = None; if !handled_in_child && state.clicked { state.clicked = false; cx.notify(); if let Some(handler) = click_handler { if hit_bounds.contains_point(*position) { - handler(cx); + handler(*click_count, cx); } } true diff --git a/crates/gpui/src/platform/event.rs b/crates/gpui/src/platform/event.rs index fe353fed4c9be36df5b74aa474be07d5123f3ad1..b32ab952c79dfbef1b1a539bec117463954c25bf 100644 --- a/crates/gpui/src/platform/event.rs +++ b/crates/gpui/src/platform/event.rs @@ -28,6 +28,7 @@ pub enum Event { }, LeftMouseUp { position: Vector2F, + click_count: usize, }, LeftMouseDragged { position: Vector2F, @@ -68,7 +69,7 @@ impl Event { Event::KeyDown { .. } => None, Event::ScrollWheel { position, .. } | Event::LeftMouseDown { position, .. } - | Event::LeftMouseUp { position } + | Event::LeftMouseUp { position, .. } | Event::LeftMouseDragged { position } | Event::RightMouseDown { position, .. } | Event::RightMouseUp { position } diff --git a/crates/gpui/src/platform/mac/event.rs b/crates/gpui/src/platform/mac/event.rs index 7170bd2fd598d81301a3d10342f93c24040301d9..651805370c0be39bc17d5a0dde379f7c9e825a07 100644 --- a/crates/gpui/src/platform/mac/event.rs +++ b/crates/gpui/src/platform/mac/event.rs @@ -129,6 +129,7 @@ impl Event { native_event.locationInWindow().x as f32, window_height - native_event.locationInWindow().y as f32, ), + click_count: native_event.clickCount() as usize, }), NSEventType::NSRightMouseDown => { let modifiers = native_event.modifierFlags(); diff --git a/crates/gpui/src/views/select.rs b/crates/gpui/src/views/select.rs index 10cd0cd5a2934912665917e85237d2bb67b28575..d5d2105c3f34e6b74126080771118f07df8903af 100644 --- a/crates/gpui/src/views/select.rs +++ b/crates/gpui/src/views/select.rs @@ -119,7 +119,7 @@ impl View for Select { .with_style(style.header) .boxed() }) - .on_click(move |cx| cx.dispatch_action(ToggleSelect)) + .on_click(move |_, cx| cx.dispatch_action(ToggleSelect)) .boxed(), ); if self.is_open { @@ -153,7 +153,7 @@ impl View for Select { ) }, ) - .on_click(move |cx| cx.dispatch_action(SelectItem(ix))) + .on_click(move |_, cx| cx.dispatch_action(SelectItem(ix))) .boxed() })) }, diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 6bb4f640ee8a92b3b906f0bea121586d5ee266b0..220278fd1d627426c1e96fda6a205e555b680d3f 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -69,7 +69,10 @@ struct EntryDetails { pub struct ToggleExpanded(pub ProjectEntryId); #[derive(Clone)] -pub struct Open(pub ProjectEntryId); +pub struct Open { + pub entry_id: ProjectEntryId, + pub change_focus: bool, +} actions!( project_panel, @@ -339,7 +342,7 @@ impl ProjectPanel { } fn open_entry(&mut self, action: &Open, cx: &mut ViewContext) { - cx.emit(Event::OpenedEntry(action.0)); + cx.emit(Event::OpenedEntry(action.entry_id)); } fn add_file(&mut self, _: &AddFile, cx: &mut ViewContext) { @@ -799,11 +802,14 @@ impl ProjectPanel { .with_padding_left(padding) .boxed() }) - .on_click(move |cx| { + .on_click(move |click_count, cx| { if kind == EntryKind::Dir { cx.dispatch_action(ToggleExpanded(entry_id)) } else { - cx.dispatch_action(Open(entry_id)) + cx.dispatch_action(Open { + entry_id, + change_focus: click_count > 1, + }) } }) .with_cursor_style(CursorStyle::PointingHand) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index d1f17608f28c98f4e805e865890211104bd8449a..549edf89e71cdc356f20b3911b39922323cbef19 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -292,7 +292,7 @@ impl BufferSearchBar { .with_style(style.container) .boxed() }) - .on_click(move |cx| cx.dispatch_action(ToggleSearchOption(search_option))) + .on_click(move |_, cx| cx.dispatch_action(ToggleSearchOption(search_option))) .with_cursor_style(CursorStyle::PointingHand) .boxed() } @@ -316,7 +316,7 @@ impl BufferSearchBar { .with_style(style.container) .boxed() }) - .on_click(move |cx| match direction { + .on_click(move |_, cx| match direction { Direction::Prev => cx.dispatch_action(SelectPrevMatch), Direction::Next => cx.dispatch_action(SelectNextMatch), }) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index d3b3520a53b36c324714718145c138e9aa6e006d..cbd373c468f700533d24065568f41e54960a4141 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -666,7 +666,7 @@ impl ProjectSearchBar { .with_style(style.container) .boxed() }) - .on_click(move |cx| match direction { + .on_click(move |_, cx| match direction { Direction::Prev => cx.dispatch_action(SelectPrevMatch), Direction::Next => cx.dispatch_action(SelectNextMatch), }) @@ -693,7 +693,7 @@ impl ProjectSearchBar { .with_style(style.container) .boxed() }) - .on_click(move |cx| cx.dispatch_action(ToggleSearchOption(option))) + .on_click(move |_, cx| cx.dispatch_action(ToggleSearchOption(option))) .with_cursor_style(CursorStyle::PointingHand) .boxed() } diff --git a/crates/workspace/src/lsp_status.rs b/crates/workspace/src/lsp_status.rs index ddc6d893086dfe71d73fa57f887800fa64445749..f58e0b973e05e27db44359b95c11524010e14ea2 100644 --- a/crates/workspace/src/lsp_status.rs +++ b/crates/workspace/src/lsp_status.rs @@ -168,7 +168,7 @@ impl View for LspStatus { self.failed.join(", "), if self.failed.len() > 1 { "s" } else { "" } ); - handler = Some(|cx: &mut EventContext| cx.dispatch_action(DismissErrorMessage)); + handler = Some(|_, cx: &mut EventContext| cx.dispatch_action(DismissErrorMessage)); } else { return Empty::new().boxed(); } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index a992897c1182c9e03a5ee515d6a71fd7cf2bc8d7..94fe7c3a42f67db6b517d8cd75cd0313107c15d4 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -737,7 +737,7 @@ impl Pane { .with_cursor_style(CursorStyle::PointingHand) .on_click({ let pane = pane.clone(); - move |cx| { + move |_, cx| { cx.dispatch_action(CloseItem { item_id, pane: pane.clone(), diff --git a/crates/workspace/src/sidebar.rs b/crates/workspace/src/sidebar.rs index 2f13469cec47ca08b7904c1d3885523932cd277a..bc7314e73286b48ed7f2ca95bb56cd7e93f71de8 100644 --- a/crates/workspace/src/sidebar.rs +++ b/crates/workspace/src/sidebar.rs @@ -203,7 +203,7 @@ impl View for SidebarButtons { .boxed() }) .with_cursor_style(CursorStyle::PointingHand) - .on_click(move |cx| { + .on_click(move |_, cx| { cx.dispatch_action(ToggleSidebarItem { side, item_index: ix, diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d072c515503edb02ad6f52d9c55c87ca850d02d8..fe18fcb95a72d0c8ba05fbf3e0ae5fd48cf5796f 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1584,7 +1584,7 @@ impl Workspace { .with_style(style.container) .boxed() }) - .on_click(|cx| cx.dispatch_action(Authenticate)) + .on_click(|_, cx| cx.dispatch_action(Authenticate)) .with_cursor_style(CursorStyle::PointingHand) .aligned() .boxed(), @@ -1635,7 +1635,7 @@ impl Workspace { if let Some(peer_id) = peer_id { MouseEventHandler::new::(replica_id.into(), cx, move |_, _| content) .with_cursor_style(CursorStyle::PointingHand) - .on_click(move |cx| cx.dispatch_action(ToggleFollow(peer_id))) + .on_click(move |_, cx| cx.dispatch_action(ToggleFollow(peer_id))) .boxed() } else { content @@ -1667,7 +1667,7 @@ impl Workspace { .boxed() }) .with_cursor_style(CursorStyle::PointingHand) - .on_click(|cx| cx.dispatch_action(ToggleShare)) + .on_click(|_, cx| cx.dispatch_action(ToggleShare)) .boxed(), ) } else {