This commit is contained in:
Delan Azabani 2025-09-18 18:03:32 +08:00
parent af7de5ccf1
commit d2f793f837
3 changed files with 17 additions and 0 deletions

View file

@ -1472,4 +1472,13 @@ impl DocumentEventHandler {
document.handle_element_scroll_event(&element); document.handle_element_scroll_event(&element);
} }
} }
pub(crate) fn run_default_keyboard_event_handler(&self, event: &KeyboardEvent, can_gc: CanGc) {
if event.upcast::<Event>().type_() != atom!("keydown") {
return;
}
// keydown
dbg!(event.upcast::<Event>().type_());
}
} }

View file

@ -121,6 +121,7 @@ use crate::dom::shadowroot::{IsUserAgentWidget, LayoutShadowRootHelpers, ShadowR
use crate::dom::stylesheetlist::StyleSheetListOwner; use crate::dom::stylesheetlist::StyleSheetListOwner;
use crate::dom::svgsvgelement::{LayoutSVGSVGElementHelpers, SVGSVGElement}; use crate::dom::svgsvgelement::{LayoutSVGSVGElementHelpers, SVGSVGElement};
use crate::dom::text::Text; use crate::dom::text::Text;
use crate::dom::types::KeyboardEvent;
use crate::dom::virtualmethods::{VirtualMethods, vtable_for}; use crate::dom::virtualmethods::{VirtualMethods, vtable_for};
use crate::dom::window::Window; use crate::dom::window::Window;
use crate::script_runtime::CanGc; use crate::script_runtime::CanGc;
@ -4084,6 +4085,12 @@ impl VirtualMethods for Node {
self.ranges().drain_to_parent(context, self); self.ranges().drain_to_parent(context, self);
} }
} }
fn handle_event(&self, event: &Event, can_gc: CanGc) {
if let Some(event) = event.downcast::<KeyboardEvent>() {
self.owner_document().event_handler().run_default_keyboard_event_handler(event, can_gc);
}
}
} }
/// A summary of the changes that happened to a node. /// A summary of the changes that happened to a node.

View file

@ -455,6 +455,7 @@ impl RunningAppState {
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || {
let location = ScrollLocation::Delta(Vector2D::new(0.0, LINE_HEIGHT)); let location = ScrollLocation::Delta(Vector2D::new(0.0, LINE_HEIGHT));
webview.notify_scroll_event(location, origin); webview.notify_scroll_event(location, origin);
dbg!("here");
}) })
.shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || {
let location = ScrollLocation::Delta(Vector2D::new(-LINE_WIDTH, 0.0)); let location = ScrollLocation::Delta(Vector2D::new(-LINE_WIDTH, 0.0));