Allow clicking on commands in the command palette
This commit is contained in:
parent
4ef95f05e8
commit
ad017a5df5
5 changed files with 104 additions and 25 deletions
|
@ -2,7 +2,7 @@ use gpui::{
|
|||
div, px, AnyView, Div, EventEmitter, FocusHandle, ParentElement, Render, StatelessInteractive,
|
||||
Styled, Subscription, View, ViewContext, VisualContext, WindowContext,
|
||||
};
|
||||
use ui::v_stack;
|
||||
use ui::{h_stack, v_stack};
|
||||
|
||||
pub struct ActiveModal {
|
||||
modal: AnyView,
|
||||
|
@ -33,8 +33,6 @@ impl ModalLayer {
|
|||
V: Modal,
|
||||
B: FnOnce(&mut ViewContext<V>) -> V,
|
||||
{
|
||||
let previous_focus = cx.focused();
|
||||
|
||||
if let Some(active_modal) = &self.active_modal {
|
||||
let is_close = active_modal.modal.clone().downcast::<V>().is_ok();
|
||||
self.hide_modal(cx);
|
||||
|
@ -85,9 +83,6 @@ impl Render for ModalLayer {
|
|||
|
||||
div()
|
||||
.absolute()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.size_full()
|
||||
.top_0()
|
||||
.left_0()
|
||||
|
@ -96,11 +91,21 @@ impl Render for ModalLayer {
|
|||
v_stack()
|
||||
.h(px(0.0))
|
||||
.top_20()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.track_focus(&active_modal.focus_handle)
|
||||
.on_mouse_down_out(|this: &mut Self, event, cx| {
|
||||
this.hide_modal(cx);
|
||||
})
|
||||
.child(active_modal.modal.clone()),
|
||||
.child(
|
||||
h_stack()
|
||||
// needed to prevent mouse events leaking to the
|
||||
// UI below. // todo! for gpui3.
|
||||
.on_any_mouse_down(|_, _, cx| cx.stop_propagation())
|
||||
.on_any_mouse_up(|_, _, cx| cx.stop_propagation())
|
||||
.on_mouse_down_out(|this: &mut Self, event, cx| {
|
||||
this.hide_modal(cx);
|
||||
})
|
||||
.child(active_modal.modal.clone()),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue