Remove on_click_out handler from context menu

Add 'delay_cancel()' method and on_down handler to relevant buttons
This commit is contained in:
Mikayla Maki 2023-06-29 17:10:51 -07:00
parent 6ffa6afd20
commit 5366631173
No known key found for this signature in database
6 changed files with 79 additions and 27 deletions

View file

@ -273,6 +273,7 @@ impl Pane {
Some(("New...".into(), None)),
cx,
|pane, cx| pane.deploy_new_menu(cx),
|pane, cx| pane.tab_bar_context_menu.handle.update(cx, |menu, _| menu.delay_cancel()),
pane.tab_bar_context_menu
.handle_if_kind(TabBarContextMenuKind::New),
))
@ -283,6 +284,7 @@ impl Pane {
Some(("Split Pane".into(), None)),
cx,
|pane, cx| pane.deploy_split_menu(cx),
|pane, cx| pane.tab_bar_context_menu.handle.update(cx, |menu, _| menu.delay_cancel()),
pane.tab_bar_context_menu
.handle_if_kind(TabBarContextMenuKind::Split),
))
@ -304,6 +306,7 @@ impl Pane {
Some((tooltip_label, Some(Box::new(ToggleZoom)))),
cx,
move |pane, cx| pane.toggle_zoom(&Default::default(), cx),
move |_, _| {},
None,
)
})
@ -988,7 +991,7 @@ impl Pane {
fn deploy_split_menu(&mut self, cx: &mut ViewContext<Self>) {
self.tab_bar_context_menu.handle.update(cx, |menu, cx| {
menu.show(
menu.toggle(
Default::default(),
AnchorCorner::TopRight,
vec![
@ -1006,7 +1009,7 @@ impl Pane {
fn deploy_new_menu(&mut self, cx: &mut ViewContext<Self>) {
self.tab_bar_context_menu.handle.update(cx, |menu, cx| {
menu.show(
menu.toggle(
Default::default(),
AnchorCorner::TopRight,
vec![
@ -1416,13 +1419,14 @@ impl Pane {
.into_any()
}
pub fn render_tab_bar_button<F: 'static + Fn(&mut Pane, &mut EventContext<Pane>)>(
pub fn render_tab_bar_button<F1: 'static + Fn(&mut Pane, &mut EventContext<Pane>), F2: 'static + Fn(&mut Pane, &mut EventContext<Pane>)>(
index: usize,
icon: &'static str,
is_active: bool,
tooltip: Option<(String, Option<Box<dyn Action>>)>,
cx: &mut ViewContext<Pane>,
on_click: F,
on_click: F1,
on_down: F2,
context_menu: Option<ViewHandle<ContextMenu>>,
) -> AnyElement<Pane> {
enum TabBarButton {}
@ -1440,6 +1444,7 @@ impl Pane {
.with_height(style.button_width)
})
.with_cursor_style(CursorStyle::PointingHand)
.on_down(MouseButton::Left, move |_, pane, cx| on_down(pane, cx))
.on_click(MouseButton::Left, move |_, pane, cx| on_click(pane, cx))
.into_any();
if let Some((tooltip, action)) = tooltip {