enter in textarea handled
This commit is contained in:
parent
417ac55fda
commit
6438cf52d1
|
@ -31,6 +31,7 @@ class NoReset(Reset):
|
||||||
class KeyboardPress(Message):
|
class KeyboardPress(Message):
|
||||||
def on_event(self, event):
|
def on_event(self, event):
|
||||||
self.add_arg(event.key)
|
self.add_arg(event.key)
|
||||||
|
self.add_arg(event)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
key = self.get_arg(0, str)
|
key = self.get_arg(0, str)
|
||||||
|
@ -39,11 +40,19 @@ class KeyboardPress(Message):
|
||||||
def data_change(self):
|
def data_change(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _handle_textarea(self):
|
||||||
|
event = self.get_arg(1)
|
||||||
|
if event.target["type"] == "textarea":
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
key = self.get_arg(0, str)
|
key = self.get_arg(0, str)
|
||||||
|
|
||||||
# Enter when modal shown -> press ok button
|
# Enter when modal shown -> press ok button
|
||||||
if model.modal_shown and key == "Enter":
|
if model.modal_shown and key == "Enter":
|
||||||
|
# handle textarea as per user wishes
|
||||||
|
self._handle_textarea()
|
||||||
|
|
||||||
ok_button = document.getElementById("modal-ok")
|
ok_button = document.getElementById("modal-ok")
|
||||||
if ok_button is not None:
|
if ok_button is not None:
|
||||||
# has to be called in separate thread
|
# has to be called in separate thread
|
||||||
|
|
|
@ -16,7 +16,7 @@ class View:
|
||||||
patch(container, self.vdom)
|
patch(container, self.vdom)
|
||||||
|
|
||||||
# this does not work on parent div, so attaching to document here
|
# this does not work on parent div, so attaching to document here
|
||||||
document.addEventListener("keyup", msg(KeyboardPress))
|
document.addEventListener("keydown", msg(KeyboardPress))
|
||||||
|
|
||||||
def view(self, model, data_change):
|
def view(self, model, data_change):
|
||||||
self.model = model
|
self.model = model
|
||||||
|
|
Loading…
Reference in New Issue
Block a user