mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 20:11:49 +03:00
Remove internal actions from menu
crate
This commit is contained in:
parent
816eb06a7b
commit
15d83d40b0
@ -1,6 +1,3 @@
|
|||||||
#[derive(Clone, PartialEq)]
|
|
||||||
pub struct SelectIndex(pub usize);
|
|
||||||
|
|
||||||
gpui::actions!(
|
gpui::actions!(
|
||||||
menu,
|
menu,
|
||||||
[
|
[
|
||||||
@ -12,5 +9,3 @@ gpui::actions!(
|
|||||||
SelectLast
|
SelectLast
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
gpui::impl_internal_actions!(menu, [SelectIndex]);
|
|
||||||
|
@ -7,7 +7,7 @@ use gpui::{
|
|||||||
AnyElement, AnyViewHandle, AppContext, Axis, Entity, MouseState, Task, View, ViewContext,
|
AnyElement, AnyViewHandle, AppContext, Axis, Entity, MouseState, Task, View, ViewContext,
|
||||||
ViewHandle,
|
ViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Cancel, Confirm, SelectFirst, SelectIndex, SelectLast, SelectNext, SelectPrev};
|
use menu::{Cancel, Confirm, SelectFirst, SelectLast, SelectNext, SelectPrev};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{cmp, sync::Arc};
|
use std::{cmp, sync::Arc};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
@ -104,8 +104,8 @@ impl<D: PickerDelegate> View for Picker<D> {
|
|||||||
// Capture mouse events
|
// Capture mouse events
|
||||||
.on_down(MouseButton::Left, |_, _, _| {})
|
.on_down(MouseButton::Left, |_, _, _| {})
|
||||||
.on_up(MouseButton::Left, |_, _, _| {})
|
.on_up(MouseButton::Left, |_, _, _| {})
|
||||||
.on_click(MouseButton::Left, move |_, _, cx| {
|
.on_click(MouseButton::Left, move |_, picker, cx| {
|
||||||
cx.dispatch_action(SelectIndex(ix))
|
picker.select_index(ix, cx);
|
||||||
})
|
})
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.into_any()
|
.into_any()
|
||||||
@ -151,7 +151,6 @@ impl<D: PickerDelegate> Picker<D> {
|
|||||||
cx.add_action(Self::select_last);
|
cx.add_action(Self::select_last);
|
||||||
cx.add_action(Self::select_next);
|
cx.add_action(Self::select_next);
|
||||||
cx.add_action(Self::select_prev);
|
cx.add_action(Self::select_prev);
|
||||||
cx.add_action(Self::select_index);
|
|
||||||
cx.add_action(Self::confirm);
|
cx.add_action(Self::confirm);
|
||||||
cx.add_action(Self::cancel);
|
cx.add_action(Self::cancel);
|
||||||
}
|
}
|
||||||
@ -265,8 +264,7 @@ impl<D: PickerDelegate> Picker<D> {
|
|||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select_index(&mut self, action: &SelectIndex, cx: &mut ViewContext<Self>) {
|
pub fn select_index(&mut self, index: usize, cx: &mut ViewContext<Self>) {
|
||||||
let index = action.0;
|
|
||||||
if self.delegate.match_count() > 0 {
|
if self.delegate.match_count() > 0 {
|
||||||
self.confirmed = true;
|
self.confirmed = true;
|
||||||
self.delegate.set_selected_index(index, cx);
|
self.delegate.set_selected_index(index, cx);
|
||||||
|
Loading…
Reference in New Issue
Block a user