-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabTextInput.py
More file actions
23 lines (16 loc) · 776 Bytes
/
TabTextInput.py
File metadata and controls
23 lines (16 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from kivy.uix.textinput import TextInput
"""Credit to dgel on StackOverflow for this code:
http://stackoverflow.com/questions/12037379/tab-enter-and-other-keystrokes-handling-in-kivys-textinput-widgets"""
class TabTextInput(TextInput):
def __init__(self, *args, **kwargs):
self.next = kwargs.pop('next', None)
super(TabTextInput, self).__init__(*args, **kwargs)
def set_next(self, next):
self.next = next
def _keyboard_on_key_down(self, window, keycode, text, modifiers):
key, key_str = keycode
if key in (9, 13) and self.next is not None:
self.next.focus = True
self.next.select_all()
else:
super(TabTextInput, self)._keyboard_on_key_down(window, keycode, text, modifiers)