mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 13:10:54 +00:00
Remove internal actions from ContextMenu
This commit is contained in:
parent
022368225e
commit
32f21771a6
1 changed files with 2 additions and 13 deletions
|
@ -2,7 +2,6 @@ use gpui::{
|
||||||
anyhow,
|
anyhow,
|
||||||
elements::*,
|
elements::*,
|
||||||
geometry::vector::Vector2F,
|
geometry::vector::Vector2F,
|
||||||
impl_internal_actions,
|
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
platform::{CursorStyle, MouseButton},
|
platform::{CursorStyle, MouseButton},
|
||||||
Action, AnyViewHandle, AppContext, Axis, Entity, MouseState, SizeConstraint, Subscription,
|
Action, AnyViewHandle, AppContext, Axis, Entity, MouseState, SizeConstraint, Subscription,
|
||||||
|
@ -12,17 +11,11 @@ use menu::*;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{any::TypeId, borrow::Cow, sync::Arc, time::Duration};
|
use std::{any::TypeId, borrow::Cow, sync::Arc, time::Duration};
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
|
||||||
struct Clicked;
|
|
||||||
|
|
||||||
impl_internal_actions!(context_menu, [Clicked]);
|
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(ContextMenu::select_first);
|
cx.add_action(ContextMenu::select_first);
|
||||||
cx.add_action(ContextMenu::select_last);
|
cx.add_action(ContextMenu::select_last);
|
||||||
cx.add_action(ContextMenu::select_next);
|
cx.add_action(ContextMenu::select_next);
|
||||||
cx.add_action(ContextMenu::select_prev);
|
cx.add_action(ContextMenu::select_prev);
|
||||||
cx.add_action(ContextMenu::clicked);
|
|
||||||
cx.add_action(ContextMenu::confirm);
|
cx.add_action(ContextMenu::confirm);
|
||||||
cx.add_action(ContextMenu::cancel);
|
cx.add_action(ContextMenu::cancel);
|
||||||
}
|
}
|
||||||
|
@ -228,10 +221,6 @@ impl ContextMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clicked(&mut self, _: &Clicked, _: &mut ViewContext<Self>) {
|
|
||||||
self.clicked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
|
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(ix) = self.selected_index {
|
if let Some(ix) = self.selected_index {
|
||||||
if let Some(ContextMenuItem::Item { action, .. }) = self.items.get(ix) {
|
if let Some(ContextMenuItem::Item { action, .. }) = self.items.get(ix) {
|
||||||
|
@ -465,9 +454,9 @@ impl ContextMenu {
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_up(MouseButton::Left, |_, _, _| {}) // Capture these events
|
.on_up(MouseButton::Left, |_, _, _| {}) // Capture these events
|
||||||
.on_down(MouseButton::Left, |_, _, _| {}) // Capture these events
|
.on_down(MouseButton::Left, |_, _, _| {}) // Capture these events
|
||||||
.on_click(MouseButton::Left, move |_, _, cx| {
|
.on_click(MouseButton::Left, move |_, menu, cx| {
|
||||||
|
menu.clicked = true;
|
||||||
let window_id = cx.window_id();
|
let window_id = cx.window_id();
|
||||||
cx.dispatch_action(Clicked);
|
|
||||||
match &action {
|
match &action {
|
||||||
ContextMenuItemAction::Action(action) => {
|
ContextMenuItemAction::Action(action) => {
|
||||||
cx.dispatch_any_action_at(
|
cx.dispatch_any_action_at(
|
||||||
|
|
Loading…
Reference in a new issue