From 8b9802c21dc40aee0c7344849aba1995dc7cfa71 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 5 Nov 2010 15:05:47 +0200 Subject: [PATCH] Don't complicate stuff when it can be done very simple; make use of wx.FindWindowAtPointer to detect our drop targets --- gui/shipBrowser.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 0fe6aeeb9..479cd1660 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -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