diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-03-28 17:29:49 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:41 +0300 |
commit | 1aa4eaa3142661ceb5df871fd0361abf289682a0 (patch) | |
tree | cc9dd6022a0be4fbe349b572da1ab72688a32ed8 | |
parent | 1867bb6aa35408461ab699b56267a249432f6d91 (diff) |
ui: add paste event to Field
-rw-r--r-- | ui/src/components/utilities/widgets.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ui/src/components/utilities/widgets.rs b/ui/src/components/utilities/widgets.rs index 3b397254..1867e461 100644 --- a/ui/src/components/utilities/widgets.rs +++ b/ui/src/components/utilities/widgets.rs @@ -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); } |