Add single-line text input with no visible cursor.

This commit is contained in:
Josh Matthews 2014-10-06 11:51:44 -04:00
parent 84bc17e7ad
commit 80764f65e3
8 changed files with 776 additions and 63 deletions

View file

@ -49,7 +49,7 @@ use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading};
use servo_msg::compositor_msg::{ScriptListener};
use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg, LoadUrlMsg, NavigationDirection};
use servo_msg::constellation_msg::{LoadData, PipelineId, Failure, FailureMsg, WindowSizeData, Key, KeyState};
use servo_msg::constellation_msg::{KeyModifiers, Super, Shift, Control, Alt, Repeated, Pressed};
use servo_msg::constellation_msg::{KeyModifiers, SUPER, SHIFT, CONTROL, ALT, Repeated, Pressed};
use servo_msg::constellation_msg::{Released};
use servo_msg::constellation_msg;
use servo_net::image_cache_task::ImageCacheTask;
@ -923,7 +923,6 @@ impl ScriptTask {
state: KeyState,
modifiers: KeyModifiers,
pipeline_id: PipelineId) {
println!("key {} is {}", key as int, state as int);
let page = get_page(&*self.page.borrow(), pipeline_id);
let frame = page.frame();
let window = frame.as_ref().unwrap().window.root();
@ -937,10 +936,10 @@ impl ScriptTask {
(&None, &None) => EventTargetCast::from_ref(*window),
};
let ctrl = modifiers.contains(Control);
let alt = modifiers.contains(Alt);
let shift = modifiers.contains(Shift);
let meta = modifiers.contains(Super);
let ctrl = modifiers.contains(CONTROL);
let alt = modifiers.contains(ALT);
let shift = modifiers.contains(SHIFT);
let meta = modifiers.contains(SUPER);
let is_composing = false;
let is_repeating = state == Repeated;
@ -949,21 +948,24 @@ impl ScriptTask {
Released => "keyup",
}.to_string();
let props = KeyboardEvent::key_properties(key);
let props = KeyboardEvent::key_properties(key, modifiers);
let event = KeyboardEvent::new(*window, ev_type, true, true, Some(*window), 0,
props.key.clone(), props.code.clone(), props.location,
props.key.to_string(), props.code.to_string(), props.location,
is_repeating, is_composing, ctrl, alt, shift, meta,
props.char_code, props.key_code).root();
None, props.key_code).root();
let _ = target.DispatchEvent(EventCast::from_ref(*event));
if state != Released && props.is_printable() {
let event = KeyboardEvent::new(*window, "keypress".to_string(), true, true, Some(*window),
0, props.key.clone(), props.code.clone(), props.location,
is_repeating, is_composing, ctrl, alt, shift, meta,
props.char_code, props.key_code).root();
0, props.key.to_string(), props.code.to_string(),
props.location, is_repeating, is_composing,
ctrl, alt, shift, meta,
props.char_code, 0).root();
let _ = target.DispatchEvent(EventCast::from_ref(*event));
}
window.flush_layout();
}
/// The entry point for content to notify that a new load has been requested