Wire up global actions

Added an ephemeral root node so that even if there's no window/focused handle we still have something to dispatch to.

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Piotr Osiewicz 2023-12-06 16:15:53 +01:00
parent 1f538c5fdd
commit d09dfe01f5
5 changed files with 162 additions and 132 deletions

View file

@ -55,7 +55,7 @@ pub trait InteractiveElement: Sized + Element {
E: Debug,
{
if let Some(key_context) = key_context.try_into().log_err() {
self.interactivity().key_context = key_context;
self.interactivity().key_context = Some(key_context);
}
self
}
@ -722,7 +722,7 @@ impl DivState {
pub struct Interactivity {
pub element_id: Option<ElementId>,
pub key_context: KeyContext,
pub key_context: Option<KeyContext>,
pub focusable: bool,
pub tracked_focus_handle: Option<FocusHandle>,
pub scroll_handle: Option<ScrollHandle>,
@ -1238,7 +1238,7 @@ impl Default for Interactivity {
fn default() -> Self {
Self {
element_id: None,
key_context: KeyContext::default(),
key_context: None,
focusable: false,
tracked_focus_handle: None,
scroll_handle: None,