Add Modal::has_focus
and introduce a ModalHandle
trait object
This commit is contained in:
parent
25564ea058
commit
a8602b2a0c
3 changed files with 38 additions and 0 deletions
|
@ -97,9 +97,25 @@ lazy_static! {
|
|||
}
|
||||
|
||||
pub trait Modal: View {
|
||||
fn has_focus(&self) -> bool;
|
||||
fn dismiss_on_event(event: &Self::Event) -> bool;
|
||||
}
|
||||
|
||||
trait ModalHandle {
|
||||
fn as_any(&self) -> &AnyViewHandle;
|
||||
fn has_focus(&self, cx: &WindowContext) -> bool;
|
||||
}
|
||||
|
||||
impl<T: Modal> ModalHandle for ViewHandle<T> {
|
||||
fn as_any(&self) -> &AnyViewHandle {
|
||||
self
|
||||
}
|
||||
|
||||
fn has_focus(&self, cx: &WindowContext) -> bool {
|
||||
self.read(cx).has_focus()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct RemoveWorktreeFromProject(pub WorktreeId);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue