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