def _window_on_key_down(self, key, scancode=None, unicode=None): modifiers = getWindow().modifiers if key == ord('v') and 'ctrl' in modifiers: text = Clipboard.get('text/plain') if text: self.keyboard.text += text return True if key == 27: # escape self.hide_keyboard() return True elif key == 9: # tab self.focus_next() return True if not self.keyboard: return k = self.interesting_keys.get(key) if k: key = (None, None, k, 1) self.keyboard.dispatch_event('on_key_down', key) else: if unicode is not None: self.keyboard.text += unicode else: self.keyboard.text += chr(key)
def _window_on_key_down(self, key, scancode=None, unicode=None): if unicode and not key in self.interesting_keys.keys() + [27]: modifiers = getWindow().modifiers if 'ctrl' in modifiers: if key == ord('x'): # cut selection Clipboard.put(self._selection_text, 'text/plain') self.delete_selection() elif key == ord('c'): # copy selection Clipboard.put(self._selection_text, 'text/plain') elif key == ord('v'): # paste selection data = Clipboard.get('text/plain') if data: self.delete_selection() self.insert_text(data) elif key == ord('a'): # select all self._selection_from = 0 self._selection_to = len(self.value) self._update_selection(True) else: if self._selection: self.delete_selection() self.insert_text(unicode) self._recalc_size() return super(MTTextArea, self)._window_on_key_down(key, scancode, unicode)