Commit 437f0699 authored by Duane Johnson's avatar Duane Johnson

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

parent 50d340f9
...@@ -67,6 +67,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -67,6 +67,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.Frame.__init__(self,None,title=_("Printer Interface"),size=size); wx.Frame.__init__(self,None,title=_("Printer Interface"),size=size);
self.SetIcon(wx.Icon("P-face.ico",wx.BITMAP_TYPE_ICO)) self.SetIcon(wx.Icon("P-face.ico",wx.BITMAP_TYPE_ICO))
self.panel=wx.Panel(self,-1,size=size) self.panel=wx.Panel(self,-1,size=size)
self.panel.SetBackgroundColour("white")
self.statuscheck=False self.statuscheck=False
self.tempreport="" self.tempreport=""
self.monitor=0 self.monitor=0
...@@ -120,7 +121,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -120,7 +121,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.starttime=0 self.starttime=0
self.curlayer=0 self.curlayer=0
self.cur_button=None self.cur_button=None
self.SetBackgroundColour("white")
def startcb(self): def startcb(self):
self.starttime=time.time() self.starttime=time.time()
......
...@@ -36,8 +36,15 @@ class XYButtons(BufferedCanvas): ...@@ -36,8 +36,15 @@ class XYButtons(BufferedCanvas):
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown)
self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) 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): def onKey(self, evt):
if self.keypad_idx >= 0: if self.keypad_idx >= 0:
if evt.GetKeyCode() == wx.WXK_TAB: if evt.GetKeyCode() == wx.WXK_TAB:
...@@ -52,11 +59,13 @@ class XYButtons(BufferedCanvas): ...@@ -52,11 +59,13 @@ class XYButtons(BufferedCanvas):
self.quadrant = 0 self.quadrant = 0
else: else:
evt.Skip() evt.Skip()
return False return
if self.moveCallback: if self.moveCallback:
self.concentric = self.keypad_idx self.concentric = self.keypad_idx
x, y = self.getMovement() x, y = self.getMovement()
self.moveCallback(x, y) self.moveCallback(x, y)
evt.Skip()
def rotateKeypadIndex(self): def rotateKeypadIndex(self):
...@@ -124,6 +133,9 @@ class XYButtons(BufferedCanvas): ...@@ -124,6 +133,9 @@ class XYButtons(BufferedCanvas):
self.update() self.update()
def OnLeftDown(self, event): def OnLeftDown(self, event):
# Take focus when clicked so that arrow keys can control movement
self.SetFocus()
mpos = event.GetPosition() mpos = event.GetPosition()
idx = self.mouseOverKeypad(mpos) idx = self.mouseOverKeypad(mpos)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment