Detailed changes
@@ -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(),
@@ -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 {
@@ -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,
@@ -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(),
);
}
@@ -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)
}
@@ -15,7 +15,7 @@ pub struct MouseEventHandler {
child: ElementBox,
cursor_style: Option<CursorStyle>,
mouse_down_handler: Option<Box<dyn FnMut(&mut EventContext)>>,
- click_handler: Option<Box<dyn FnMut(&mut EventContext)>>,
+ click_handler: Option<Box<dyn FnMut(usize, &mut EventContext)>>,
drag_handler: Option<Box<dyn FnMut(Vector2F, &mut EventContext)>>,
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
@@ -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 }
@@ -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();
@@ -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()
}))
},
@@ -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<Self>) {
- cx.emit(Event::OpenedEntry(action.0));
+ cx.emit(Event::OpenedEntry(action.entry_id));
}
fn add_file(&mut self, _: &AddFile, cx: &mut ViewContext<Self>) {
@@ -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)
@@ -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),
})
@@ -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()
}
@@ -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();
}
@@ -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(),
@@ -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,
@@ -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::<ToggleFollow, _, _>(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 {