Keybaord shortcut context menu
This commit is contained in:
parent
a37f86f294
commit
54cfcef0aa
2 changed files with 87 additions and 70 deletions
|
@ -385,10 +385,6 @@ enum ListEntry {
|
|||
ContactPlaceholder,
|
||||
}
|
||||
|
||||
// impl Entity for CollabPanel {
|
||||
// type Event = Event;
|
||||
// }
|
||||
|
||||
impl CollabPanel {
|
||||
pub fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||
cx.build_view(|cx| {
|
||||
|
@ -1687,8 +1683,6 @@ impl CollabPanel {
|
|||
ix: usize,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
// self.context_menu_on_selected = position.is_none();
|
||||
|
||||
let clipboard_channel_name = self.channel_clipboard.as_ref().and_then(|clipboard| {
|
||||
self.channel_store
|
||||
.read(cx)
|
||||
|
@ -1779,7 +1773,13 @@ impl CollabPanel {
|
|||
});
|
||||
|
||||
cx.focus_view(&context_menu);
|
||||
let subscription = cx.subscribe(&context_menu, |this, _, _: &DismissEvent, cx| {
|
||||
let subscription =
|
||||
cx.subscribe(&context_menu, |this, _, _: &DismissEvent, cx| {
|
||||
if this.context_menu.as_ref().is_some_and(|context_menu| {
|
||||
context_menu.0.focus_handle(cx).contains_focused(cx)
|
||||
}) {
|
||||
cx.focus_self();
|
||||
}
|
||||
this.context_menu.take();
|
||||
cx.notify();
|
||||
});
|
||||
|
@ -2147,8 +2147,15 @@ impl CollabPanel {
|
|||
let Some(channel) = self.selected_channel() else {
|
||||
return;
|
||||
};
|
||||
let Some(bounds) = self
|
||||
.selection
|
||||
.and_then(|ix| self.scroll_handle.bounds_for_item(ix))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
self.deploy_channel_context_menu(todo!(), channel.id, self.selection.unwrap(), cx);
|
||||
self.deploy_channel_context_menu(bounds.center(), channel.id, self.selection.unwrap(), cx);
|
||||
cx.stop_propagation();
|
||||
}
|
||||
|
||||
fn selected_channel(&self) -> Option<&Arc<Channel>> {
|
||||
|
@ -3258,6 +3265,12 @@ impl Render for CollabPanel {
|
|||
} else {
|
||||
self.render_signed_in(cx)
|
||||
})
|
||||
.children(self.context_menu.as_ref().map(|(menu, position, _)| {
|
||||
overlay()
|
||||
.position(*position)
|
||||
.anchor(gpui::AnchorCorner::TopLeft)
|
||||
.child(menu.clone())
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1492,6 +1492,10 @@ impl ScrollHandle {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn bounds_for_item(&self, ix: usize) -> Option<Bounds<Pixels>> {
|
||||
self.0.borrow().child_bounds.get(ix).cloned()
|
||||
}
|
||||
|
||||
/// scroll_to_item scrolls the minimal amount to ensure that the item is
|
||||
/// fully visible
|
||||
pub fn scroll_to_item(&self, ix: usize) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue