comparison src/browser/sat_browser/editor_widget.py @ 838:ab87da500820

browser: validate the status with ENTER (fixes bug 111)
author souliane <souliane@mailoo.org>
date Tue, 12 Jan 2016 20:34:20 +0100
parents f8a7a046ff9c
children d32b754265a0
comparison
equal deleted inserted replaced
837:620306b3d5be 838:ab87da500820
224 224
225 class SimpleTextEditor(BaseTextEditor, FocusHandler, keyb.KeyboardHandler, ClickHandler): 225 class SimpleTextEditor(BaseTextEditor, FocusHandler, keyb.KeyboardHandler, ClickHandler):
226 """Base class for manage a simple text editor.""" 226 """Base class for manage a simple text editor."""
227 227
228 CONVERT_NEW_LINES = True 228 CONVERT_NEW_LINES = True
229 VALIDATE_WITH_SHIFT_ENTER = True
229 230
230 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): 231 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None):
231 """ 232 """
232 @param content 233 @param content
233 @param modifiedCb 234 @param modifiedCb
301 def onKeyDown(self, sender, keycode, modifiers): 302 def onKeyDown(self, sender, keycode, modifiers):
302 for listener in self.edit_listeners: 303 for listener in self.edit_listeners:
303 listener(self.textarea, keycode, modifiers) # FIXME: edit_listeners must either be removed, or send an action instead of keycode/modifiers 304 listener(self.textarea, keycode, modifiers) # FIXME: edit_listeners must either be removed, or send an action instead of keycode/modifiers
304 if not self.options['listen_keyboard']: 305 if not self.options['listen_keyboard']:
305 return 306 return
306 if keycode == keyb.KEY_ENTER and modifiers & keyb.MODIFIER_SHIFT: 307 if keycode == keyb.KEY_ENTER and (not self.VALIDATE_WITH_SHIFT_ENTER or modifiers & keyb.MODIFIER_SHIFT):
307 self.textarea.setFocus(False) 308 self.textarea.setFocus(False)
308 if not self.options['listen_focus']: 309 if not self.options['listen_focus']:
309 self.edit(False) 310 self.edit(False)
310 311
311 def onLostFocus(self, sender): 312 def onLostFocus(self, sender):