mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Dispatch keydown, keyup, and keypress events at appropriate times.
This commit is contained in:
parent
e999843183
commit
329ba56fca
8 changed files with 124 additions and 19 deletions
|
@ -14,6 +14,7 @@ use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
|||
use dom::event::{Event, KeyboardEventTypeId};
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::Window;
|
||||
use servo_msg::constellation_msg;
|
||||
use servo_util::str::DOMString;
|
||||
use std::cell::{RefCell, Cell};
|
||||
|
||||
|
@ -109,6 +110,32 @@ impl KeyboardEvent {
|
|||
None, 0);
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
pub fn key_properties(key: constellation_msg::Key) -> KeyEventProperties {
|
||||
match key {
|
||||
_ => KeyEventProperties {
|
||||
key: "".to_string(),
|
||||
code: "".to_string(),
|
||||
location: 0,
|
||||
char_code: None,
|
||||
key_code: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct KeyEventProperties {
|
||||
pub key: DOMString,
|
||||
pub code: DOMString,
|
||||
pub location: u32,
|
||||
pub char_code: Option<u32>,
|
||||
pub key_code: u32,
|
||||
}
|
||||
|
||||
impl KeyEventProperties {
|
||||
pub fn is_printable(&self) -> bool {
|
||||
self.char_code.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> KeyboardEventMethods for JSRef<'a, KeyboardEvent> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue