comparison 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
comparison
equal deleted inserted replaced
399:6e38d317bc16 400:487dd238ab88
26 from pyjamas.ui.HTML import HTML 26 from pyjamas.ui.HTML import HTML
27 from pyjamas.ui.PopupPanel import PopupPanel 27 from pyjamas.ui.PopupPanel import PopupPanel
28 from pyjamas.ui.StackPanel import StackPanel 28 from pyjamas.ui.StackPanel import StackPanel
29 from pyjamas.ui.TextArea import TextArea 29 from pyjamas.ui.TextArea import TextArea
30 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT 30 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT
31 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler 31 from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_ESCAPE, KeyboardHandler
32 from pyjamas.ui.FocusListener import FocusHandler 32 from pyjamas.ui.FocusListener import FocusHandler
33 from pyjamas import DOM 33 from pyjamas import DOM
34 34
35 from datetime import datetime 35 from datetime import datetime
36 from time import time 36 from time import time
442 """ 442 """
443 @param content 443 @param content
444 @param modifiedCb 444 @param modifiedCb
445 @param afterEditCb 445 @param afterEditCb
446 @param single_line: set to True to manage a single line editor. In that 446 @param single_line: set to True to manage a single line editor. In that
447 case the edition will be terminated when the <enter> key is pressed. 447 case the edition will be terminated when <enter> or <escape> is pressed.
448 @param listen_focus: set to True to terminate the edition when the 448 @param listen_focus: set to True to terminate the edition when the
449 focus is lost. Leave to None in order to use single_line's value. 449 focus is lost. Leave to None in order to use single_line's value.
450 @param enhance_display: if True, the display text will be enhanced with addURLToText 450 @param enhance_display: if True, the display text will be enhanced with addURLToText
451 """ 451 """
452 HTML.__init__(self) 452 HTML.__init__(self)
498 listener(self, keycode) 498 listener(self, keycode)
499 499
500 def onKeyPress(self, sender, keycode, modifiers): 500 def onKeyPress(self, sender, keycode, modifiers):
501 if not self.__single_line: 501 if not self.__single_line:
502 return 502 return
503 if keycode == KEY_ENTER: # finish the edition 503 # XXX: it seems that pyjamas never catches the escape key
504 if keycode in (KEY_ENTER, KEY_ESCAPE): # finish the edition
504 self.setFocus(False) 505 self.setFocus(False)
505 if not self.__listen_focus: 506 if not self.__listen_focus:
506 self.edit(False) 507 self.edit(False)
507 508
508 def onLostFocus(self, sender): 509 def onLostFocus(self, sender):