diff browser_side/base_panels.py @ 400:487dd238ab88

browser_side: bug fixes for microblog raw/rich edition toggle
author souliane <souliane@mailoo.org>
date Tue, 11 Mar 2014 13:53:19 +0100
parents 98cd5387d291
children ea03f898067f
line wrap: on
line diff
--- a/browser_side/base_panels.py	Tue Mar 11 12:55:31 2014 +0100
+++ b/browser_side/base_panels.py	Tue Mar 11 13:53:19 2014 +0100
@@ -28,7 +28,7 @@
 from pyjamas.ui.StackPanel import StackPanel
 from pyjamas.ui.TextArea import TextArea
 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT
-from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler
+from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_ESCAPE, KeyboardHandler
 from pyjamas.ui.FocusListener import FocusHandler
 from pyjamas import DOM
 
@@ -444,7 +444,7 @@
         @param modifiedCb
         @param afterEditCb
         @param single_line: set to True to manage a single line editor. In that
-        case the edition will be terminated when the <enter> key is pressed.
+        case the edition will be terminated when <enter> or <escape> is pressed.
         @param listen_focus: set to True to terminate the edition when the
         focus is lost. Leave to None in order to use single_line's value.
         @param enhance_display: if True, the display text will be enhanced with addURLToText
@@ -500,7 +500,8 @@
     def onKeyPress(self, sender, keycode, modifiers):
         if not self.__single_line:
             return
-        if keycode == KEY_ENTER:  # finish the edition
+        # XXX: it seems that pyjamas never catches the escape key
+        if keycode in (KEY_ENTER, KEY_ESCAPE):  # finish the edition
             self.setFocus(False)
             if not self.__listen_focus:
                 self.edit(False)