comparison browser_side/panels.py @ 239:b911f2b43fd4

browser_side: added input history in the unibox: This functionality uses a file from the sat project: use the -I parameter of pyjsbuild to add sat library to your PYJSPATH. To ease also possible to use your sat source directory instead of the library, you just need to trick pyjsbuild with a symbolic link: SAT=~/workspace/sat if [[ ! -e $SAT/sat ]]; then ln -sf $SAT/src $SAT/sat; fi This will allow you to import like that in libervia.py: from sat.tools.frontend.misc import InputHistory And then you can build with: $PYJS/bin/pyjsbuild libervia --no-compile-inplace -m -I $SAT
author souliane <souliane@mailoo.org>
date Mon, 14 Oct 2013 20:54:13 +0200
parents b304cdf13a3b
children 86055ccf69c3
comparison
equal deleted inserted replaced
238:dec76d4536ad 239:b911f2b43fd4
31 from pyjamas.ui.Label import Label 31 from pyjamas.ui.Label import Label
32 from pyjamas.ui.Button import Button 32 from pyjamas.ui.Button import Button
33 from pyjamas.ui.HTML import HTML 33 from pyjamas.ui.HTML import HTML
34 from pyjamas.ui.Image import Image 34 from pyjamas.ui.Image import Image
35 from pyjamas.ui.ClickListener import ClickHandler 35 from pyjamas.ui.ClickListener import ClickHandler
36 from pyjamas.ui.KeyboardListener import KEY_ENTER 36 from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_UP, KEY_DOWN
37 from pyjamas.ui.MouseListener import MouseHandler 37 from pyjamas.ui.MouseListener import MouseHandler
38 from pyjamas.Timer import Timer 38 from pyjamas.Timer import Timer
39 from pyjamas import DOM 39 from pyjamas import DOM
40 from card_game import CardPanel 40 from card_game import CardPanel
41 from radiocol import RadioColPanel 41 from radiocol import RadioColPanel
215 self._timeCb(None) # we remove the popup 215 self._timeCb(None) # we remove the popup
216 self.showWarning(target) 216 self.showWarning(target)
217 217
218 self._timer.schedule(2000) 218 self._timer.schedule(2000)
219 219
220 def history_cb(text):
221 self.setText(text)
222 Timer(10, lambda: self.setCursorPos(len(text)))
223
220 # if keycode == KEY_ENTER and not self.visible: 224 # if keycode == KEY_ENTER and not self.visible:
221 if keycode == KEY_ENTER: 225 if keycode == KEY_ENTER:
222 if _txt: 226 if _txt:
223 target_hook, _type, msg = target 227 target_hook, _type, msg = target
224 if target_hook: 228 if target_hook:
231 self.host.bridge.call('setStatus', None, parsed_txt) 235 self.host.bridge.call('setStatus', None, parsed_txt)
232 else: 236 else:
233 print "ERROR: Unknown target hook type" 237 print "ERROR: Unknown target hook type"
234 else: # we send the message to the selected target 238 else: # we send the message to the selected target
235 self._selected_cache.onTextEntered(_txt) 239 self._selected_cache.onTextEntered(_txt)
240 self.host._updateInputHistory(_txt)
236 self.setText('') 241 self.setText('')
237 self._timeCb(None) # we remove the popup 242 self._timeCb(None) # we remove the popup
238 sender.cancelKey() 243 sender.cancelKey()
244 elif keycode == KEY_UP:
245 self.host._updateInputHistory(_txt, -1, history_cb)
246 elif keycode == KEY_DOWN:
247 self.host._updateInputHistory(_txt, +1, history_cb)
239 else: 248 else:
240 self.__onComposing() 249 self.__onComposing()
241 250
242 def getTargetAndData(self): 251 def getTargetAndData(self):
243 """For external use, to get information about the (hypothetical) message 252 """For external use, to get information about the (hypothetical) message