From: Kevin A. <ka...@us...> - 2004-09-15 15:52:13
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1466/tools/resourceEditor Modified Files: resourceEditor.py Log Message: added cursor key support for moving components Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.213 retrieving revision 1.214 diff -C2 -d -r1.213 -r1.214 *** resourceEditor.py 10 Sep 2004 19:57:52 -0000 1.213 --- resourceEditor.py 15 Sep 2004 15:52:04 -0000 1.214 *************** *** 155,158 **** --- 155,159 ---- wx.EVT_LEFT_UP(self.panel, self.on_mouseUp) wx.EVT_MOTION(self.panel, self.on_mouseDrag) + wx.EVT_KEY_DOWN(self.panel, self.on_keyPress) self.configPath = os.path.join(configuration.homedir, 'resourceeditor') *************** *** 573,576 **** --- 574,609 ---- ##event.skip() + # KEA 2004-09-15 + # support cursor keys to move components one pixel at a time + # the event is coming from the panel so we have to use the wx methods + def on_keyPress(self, event): + keyCode = event.GetKeyCode() + if keyCode in (wx.WXK_LEFT, wx.WXK_UP, wx.WXK_RIGHT, wx.WXK_DOWN): + # self.startName might not be set + # that may actually be a bug, but this should always work + s = self.propertyEditorWindow.components.wComponentList.stringSelection + if s: + name = s.split(" : ")[0] + # might make this offset match the grid value + # but leave it at one pixel for now + offset = 1 + if name in self.components: + x, y = self.components[name].position + if keyCode == wx.WXK_LEFT: + x = x - 1 + elif keyCode == wx.WXK_RIGHT: + x = x + 1 + elif keyCode == wx.WXK_UP: + y = y - 1 + elif keyCode == wx.WXK_DOWN: + y = y + 1 + self.components[name].position = (x, y) + # make sure sizing handles follow component + self.showSizingHandles(name) + # update the position on the propertyEditor status bar + self.setToolTipDrag(name, (x, y), self.components[name].size) + else: + event.Skip() + def on_mouseUp(self, event): # protect against double-clicks in the open file dialog |