+ # Find object by relative position
+ def FindObject(self, item, obj):
+ # We simply perform depth-first traversal, sinse it's too much
+ # hassle to deal with all sizer/window combinations
+ w = tree.FindNodeObject(item)
+ if w == obj:
+ return item
+ if tree.ItemHasChildren(item):
+ child = tree.GetFirstChild(item)[0]
+ while child:
+ found = self.FindObject(child, obj)
+ if found: return found
+ child = tree.GetNextSibling(child)
+ return None
+
+ def OnTestWinLeftDown(self, evt):
+ pos = evt.GetPosition()
+ self.SetHandler(g.testWin)
+ g.testWin.Disconnect(wxID_ANY, wxID_ANY, wxEVT_LEFT_DOWN)
+ item = self.FindObject(g.testWin.item, evt.GetEventObject())
+ if item:
+ tree.SelectItem(item)
+
+ def SetHandler(self, w, h=None):
+ if h:
+ w.SetEventHandler(h)
+ w.SetCursor(wxCROSS_CURSOR)
+ else:
+ w.SetEventHandler(w)
+ w.SetCursor(wxNullCursor)
+ for ch in w.GetChildren():
+ self.SetHandler(ch, h)
+
+ def OnLocate(self, evt):
+ if g.testWin:
+ self.SetHandler(g.testWin, g.testWin)
+ g.testWin.Connect(wxID_ANY, wxID_ANY, wxEVT_LEFT_DOWN, self.OnTestWinLeftDown)
+