comparison getan/states.py @ 232:01c75612253f

Remove own handling of keys for editing entry text The TextEdit widged already handles the keys by itself. Therefore the code is obsolete.
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 09 Apr 2013 19:43:53 +0200
parents 2c944fd2cd0c
children 263fe6ee0e4e
comparison
equal deleted inserted replaced
231:2c944fd2cd0c 232:01c75612253f
336 336
337 if keys.get_escape() in key: 337 if keys.get_escape() in key:
338 return self.exit() 338 return self.exit()
339 elif keys.get_enter() in key: 339 elif keys.get_enter() in key:
340 return self.enter() 340 return self.enter()
341 elif 'left' in key:
342 self.footer.set_edit_pos(pos-1)
343 return True
344 elif 'right' in key:
345 self.footer.set_edit_pos(pos+1)
346 return True
347 elif 'backspace' in key:
348 text = self.footer.edit_text
349 self.footer.set_edit_text(
350 '%s%s' % (text[0:pos-1], text[pos:len(text)]))
351 self.footer.set_edit_pos(pos-1)
352 return True
353 elif 'delete' in key:
354 text = self.footer.edit_text
355 self.footer.set_edit_text(
356 '%s%s' % (text[0:pos], text[pos+1:len(text)]))
357 self.footer.set_edit_pos(pos)
358 return True
359 elif len(key) >= 1 and len(key[0]) == 1:
360 return self.insert(key)
361 return False 341 return False
362 342
363 def enter(self): 343 def enter(self):
364 raise Exception("Not implemented") 344 raise Exception("Not implemented")
365 345
366 def exit(self): 346 def exit(self):
367 self.set_next_state(self.state) 347 self.set_next_state(self.state)
368 return True
369
370 def insert(self, key):
371 logger.debug("Enter key: %r" % key)
372 text = "".join(key)
373 # check for unicode here
374 # urwid (at least up to version 1.0.2) will crash if a non-unicode
375 # string with a char > 128 is passed here
376 if not isinstance(text, unicode):
377 text = unicode(text, locale.getpreferredencoding())
378 self.footer.insert_text(text)
379 return True 348 return True
380 349
381 350
382 class BaseTimeState(HandleUserInputState): 351 class BaseTimeState(HandleUserInputState):
383 352
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)