I’d like my busy/progress modal to be draggable, not just via the title bar, but by clicking anywhere on the Frame. Just so users can quickly get it out of the way if they want, since it has no interaction ability. It has a few widgets in it:
Panel
BoxSizer
AnimationCtrl
Gauge
Currently I’ve got it working by Bind[ing] self (the Frame) the Panel and each widget with EVT_LEFT_DOWN and EVT_LEFT_UP, and also EVT_IDLE (but just on self, the Frame).
My problem is that it looks a bit ‘choppy’. Windows gets around this by only displaying the Frame’s border while dragging. I’m not sure how I’d go about this… I could imagine doing something in OnPaint, manually drawing a square and setting it’s position until MouseUp when I move the actual Frame to the final position. But I feel like that might not work since the drawn item would be outside the Frame.
Any ideas? Here’s the relevant Frame init code:
class (wx.Frame)
def __init__:
self.Show()
self.MouseLeftIsDown = False
#bind all the widgets
self.Bind(wx.EVT_LEFT_UP, self.MouseUp)
self.TestPanel.Bind(wx.EVT_LEFT_DOWN, self.MouseDown)
self.TestPanel.Bind(wx.EVT_LEFT_UP, self.MouseUp)
self.progressGauge.Bind(wx.EVT_LEFT_DOWN, self.MouseDown)
self.progressGauge.Bind(wx.EVT_LEFT_UP, self.MouseUp)
self.beachBall.Bind(wx.EVT_LEFT_DOWN, self.MouseDown)
self.beachBall.Bind(wx.EVT_LEFT_UP, self.MouseUp)
self.Bind(wx.EVT_IDLE, self.OnIdle)
def MouseDown(self, event):
self.posInFrame = event.GetPosition()
self.MouseLeftIsDown = True
def MouseUp(self, event):
self.MouseLeftIsDown = False
def OnIdle(self, event):
if self.MouseLeftIsDown and wx.GetMouseState().LeftIsDown():
topLeftInScreen = wx.GetMousePosition()
topLeftInScreen = topLeftInScreen - self.posInFrame
self.SetPosition(topLeftInScreen)