Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-QWERTY keyboards, take 2 #11955

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Pass the char code all the way to the textinput component

  • Loading branch information
nox committed Jun 30, 2016
commit 1e3a60889ec411f3d77576b08969292474662d7f
@@ -1093,7 +1093,7 @@ impl Document {
alt,
shift,
meta,
None,
props.char_code,
props.key_code);
let event = keyevent.upcast::<Event>();
event.fire(target);
@@ -1120,7 +1120,7 @@ impl Document {
shift,
meta,
props.char_code,
0);
props.key_code);
let ev = event.upcast::<Event>();
ev.fire(target);
prevented = ev.DefaultPrevented();
@@ -19,6 +19,7 @@ use msg::constellation_msg;
use msg::constellation_msg::{Key, KeyModifiers};
use std::borrow::Cow;
use std::cell::Cell;
use std::char;

no_jsmanaged_fields!(Key);

@@ -125,6 +126,10 @@ impl KeyboardEvent {
key_code: key_keycode(key),
}
}

pub fn char(&self) -> Option<char> {
self.char_code.get().map(|code| char::from_u32(code).unwrap())
}
}


@@ -486,12 +486,17 @@ impl<T: ClipboardProvider> TextInput<T> {
/// Process a given `KeyboardEvent` and return an action for the caller to execute.
pub fn handle_keydown(&mut self, event: &KeyboardEvent) -> KeyReaction {
if let Some(key) = event.get_key() {
self.handle_keydown_aux(key, event.get_key_modifiers())
self.handle_keydown_aux(event.char(), key, event.get_key_modifiers())
} else {
KeyReaction::Nothing
}
}
pub fn handle_keydown_aux(&mut self, key: Key, mods: KeyModifiers) -> KeyReaction {

pub fn handle_keydown_aux(&mut self, ch: Option<char>, key: Key, mods: KeyModifiers) -> KeyReaction {
if let Some(ch) = ch {
self.insert_char(ch);
return KeyReaction::DispatchInput;
}
let maybe_select = if mods.contains(SHIFT) { Selection::Selected } else { Selection::NotSelected };
match key {
Key::A if is_control_key(mods) => {
@@ -401,7 +401,7 @@ fn test_clipboard_paste() {
SelectionDirection::None);
assert_eq!(textinput.get_content(), "defg");
assert_eq!(textinput.edit_point.index, 0);
textinput.handle_keydown_aux(Key::V, MODIFIERS);
textinput.handle_keydown_aux(None, Key::V, MODIFIERS);
assert_eq!(textinput.get_content(), "abcdefg");
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.