Don't complicate stuff when it can be done very simple; make use of wx.FindWindowAtPointer to detect our drop targets

This commit is contained in:
HomeWorld
2010-11-05 15:05:47 +02:00
parent 0ed842c747
commit 8b9802c21d

View File

@@ -1537,37 +1537,29 @@ class FitItem(wx.Window):
def checkPosition(self, event):
if self.dragging and self.dragged:
pos = self.ClientToScreen(event.GetPosition())
self.dragging = False
self.dragged = False
self.ReleaseMouse()
if self.HasCapture():
self.ReleaseMouse()
self.dragWindow.Show(False)
# self.dragWindow.Destroy()
msrect = self.mainFrame.fitMultiSwitch.GetRect()
mspos = self.mainFrame.fitMultiSwitch.GetPosition()
cpagewnd = self.mainFrame.fitMultiSwitch.GetCurrentPage()
fvrect = cpagewnd.GetRect()
fvpos = cpagewnd.GetPosition()
fvpos = cpagewnd.ClientToScreen(fvpos)
mspos = self.mainFrame.fitMultiSwitch.ClientToScreen(mspos)
fvrect.x = fvpos.x
fvrect.y = fvpos.y
msrect.x = mspos.x
msrect.y = mspos.y
msrect.height -= fvrect.height
fvrect.y -= msrect.height
targetWnd = wx.FindWindowAtPointer()
msWnd = self.mainFrame.fitMultiSwitch
cfitWnd = self.mainFrame.fitMultiSwitch.GetCurrentPage()
if targetWnd == cfitWnd:
if fvrect.Contains(pos):
wx.PostEvent(self.mainFrame, FitSelected(fitID=self.fitID))
elif msrect.Contains(pos):
elif targetWnd == msWnd:
if self.mainFrame.getActiveFit():
self.mainFrame.fitMultiSwitch.AddTab()
wx.PostEvent(self.mainFrame, FitSelected(fitID=self.fitID))
event.Skip()
return
if self.dragging:
self.dragging = False