ui: add paste event to Field

embed
Manos Pitsidianakis 2019-03-28 17:29:49 +02:00
parent 1867bb6aa3
commit 1aa4eaa314
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 9 additions and 2 deletions

View File

@ -162,6 +162,13 @@ impl Component for Field {
s.insert_char(k);
}
}
UIEventType::InsertInput(Key::Paste(ref p)) => {
if let Text(ref mut s, _) = self {
for c in p.chars() {
s.insert_char(c);
}
}
}
UIEventType::InsertInput(Key::Backspace) => match self {
Text(ref mut s, auto_complete) => {
s.backspace();
@ -422,11 +429,11 @@ impl Component for FormWidget {
UIEventType::ChangeMode(UIMode::Normal) if self.focus == FormFocus::TextInput => {
self.focus = FormFocus::Fields;
}
UIEventType::InsertInput(Key::Char(_)) if self.focus == FormFocus::TextInput => {
UIEventType::InsertInput(Key::Backspace) if self.focus == FormFocus::TextInput => {
let field = self.fields.get_mut(&self.layout[self.cursor]).unwrap();
field.process_event(event, context);
}
UIEventType::InsertInput(Key::Backspace) if self.focus == FormFocus::TextInput => {
UIEventType::InsertInput(_) if self.focus == FormFocus::TextInput => {
let field = self.fields.get_mut(&self.layout[self.cursor]).unwrap();
field.process_event(event, context);
}