From: <Blu...@us...> - 2010-08-08 17:38:30
|
Revision: 363 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=363&view=rev Author: BlueWolf_ Date: 2010-08-08 17:38:24 +0000 (Sun, 08 Aug 2010) Log Message: ----------- Keys with ctrl pressed won't be seen as characters anymore. Can be used as shortkeys now Modified Paths: -------------- trunk/client/gui.py Modified: trunk/client/gui.py =================================================================== --- trunk/client/gui.py 2010-08-08 15:24:53 UTC (rev 362) +++ trunk/client/gui.py 2010-08-08 17:38:24 UTC (rev 363) @@ -485,41 +485,45 @@ def keypress(self, ev): if ev.type == KEYDOWN: - if ev.key == K_LEFT: # Cursorpos change - if self.cursorpos > 0: self.cursorpos -= 1 + if ev.mod & KMOD_CTRL: # Ctrl combination + + if ev.key == K_BACKSPACE: # Remove the whole input + self.input = "" + self.cursorpos = 0 - elif ev.key == K_RIGHT: # Cursorpos change - if self.cursorpos < len(self.input): self.cursorpos += 1 + else: - elif ev.key == K_BACKSPACE: # Backspace - if ev.mod & KMOD_CTRL: - self.input = "" - self.cursorpos = 0 - else: + if ev.key == K_LEFT: # Cursorpos change + if self.cursorpos > 0: self.cursorpos -= 1 + + elif ev.key == K_RIGHT: # Cursorpos change + if self.cursorpos < len(self.input): self.cursorpos += 1 + + elif ev.key == K_BACKSPACE: # Backspace self.input = self.input[:self.cursorpos-1] + \ self.input[self.cursorpos:] if self.cursorpos > 0: self.cursorpos -= 1 - - elif ev.key == K_DELETE: # Delete - self.input = self.input[:self.cursorpos] + \ - self.input[self.cursorpos+1:] - - elif ev.key == K_HOME: # Go to the beginning - self.cursorpos = 0 - - elif ev.key == K_END: # Go to the end - self.cursorpos = len(self.input) - - elif ev.key == K_TAB: # Focus the next object - self.parent.focus_next(self) - - elif ev.unicode == "\r": # Ignore this - pass - elif ev.unicode != "": # Normal text - self.input = self.input[:self.cursorpos] + ev.unicode + \ - self.input[self.cursorpos:] - self.cursorpos += 1 + + elif ev.key == K_DELETE: # Delete + self.input = self.input[:self.cursorpos] + \ + self.input[self.cursorpos+1:] + elif ev.key == K_HOME: # Go to the beginning + self.cursorpos = 0 + + elif ev.key == K_END: # Go to the end + self.cursorpos = len(self.input) + + elif ev.key == K_TAB: # Focus the next object + self.parent.focus_next(self) + + elif ev.unicode == "\r": # Ignore this + pass + elif ev.unicode != "": # Normal text + self.input = self.input[:self.cursorpos] + ev.unicode + \ + self.input[self.cursorpos:] + self.cursorpos += 1 + self.update() if self.cb_keypress: self.cb_keypress(self, ev) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |