Fix issue with XYButtons stealing keys. Added ESC key to blur.

master
Duane Johnson 2011-11-08 10:48:15 -06:00
parent 50d340f900
commit 437f069921
2 changed files with 15 additions and 3 deletions

View File

@ -67,6 +67,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.Frame.__init__(self,None,title=_("Printer Interface"),size=size);
self.SetIcon(wx.Icon("P-face.ico",wx.BITMAP_TYPE_ICO))
self.panel=wx.Panel(self,-1,size=size)
self.panel.SetBackgroundColour("white")
self.statuscheck=False
self.tempreport=""
self.monitor=0
@ -120,7 +121,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.starttime=0
self.curlayer=0
self.cur_button=None
self.SetBackgroundColour("white")
def startcb(self):
self.starttime=time.time()

View File

@ -36,8 +36,15 @@ class XYButtons(BufferedCanvas):
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
wx.GetTopLevelParent(self).Bind(wx.EVT_CHAR_HOOK, self.onKey)
self.Bind(wx.EVT_KEY_UP, self.onKey)
wx.GetTopLevelParent(self).Bind(wx.EVT_CHAR_HOOK, self.onTopLevelKey)
def onTopLevelKey(self, evt):
# Let user press escape on any control, and return focus here
if evt.GetKeyCode() == wx.WXK_ESCAPE:
self.SetFocus()
evt.Skip()
def onKey(self, evt):
if self.keypad_idx >= 0:
if evt.GetKeyCode() == wx.WXK_TAB:
@ -52,11 +59,13 @@ class XYButtons(BufferedCanvas):
self.quadrant = 0
else:
evt.Skip()
return False
return
if self.moveCallback:
self.concentric = self.keypad_idx
x, y = self.getMovement()
self.moveCallback(x, y)
evt.Skip()
def rotateKeypadIndex(self):
@ -124,6 +133,9 @@ class XYButtons(BufferedCanvas):
self.update()
def OnLeftDown(self, event):
# Take focus when clicked so that arrow keys can control movement
self.SetFocus()
mpos = event.GetPosition()
idx = self.mouseOverKeypad(mpos)