Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Example 66: A generic TextInput that responds to enter keypress.

This is our introduction to how easy it is to create and dispatch events of our own devising.
  • Loading branch information...
commit 34487fde37c26c8c6964d2f6a44a34c1b1d590d9 1 parent 1357e9a
@buchuki authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 orkiv/__main__.py
View
16 orkiv/__main__.py
@@ -15,6 +15,22 @@
from kivy.utils import escape_markup
+class EnterTextInput(TextInput):
+ def __init__(self, **kwargs):
+ self.register_event_type("on_enter_key")
+ super(EnterTextInput, self).__init__(**kwargs)
+
+ def _keyboard_on_key_down(self, window, keycode, text, modifiers):
+ if keycode[0] == 13: # 13 is the keycode for <enter>
+ self.dispatch("on_enter_key")
+ else:
+ super(EnterTextInput, self)._keyboard_on_key_down(
+ window, keycode, text, modifiers)
+
+ def on_enter_key(self):
+ pass
+
+
class ConnectionModal(ModalView):
def __init__(self, jabber_id, password):
super(ConnectionModal, self).__init__(auto_dismiss=False,
Please sign in to comment.
Something went wrong with that request. Please try again.