Phoenix
Phoenix copied to clipboard
CustomTreeCtrl: event for right click on the "blank area" (not on any item)
wxpython 4.2.2, python 3.11 (macOS/Windows)
Looks like CustomTreeCtrl will "eat" all the right click events. For example, when right click on the "blank area" (not on any item), the "parent" will not receive any event (e.g., wx.EVT_CONTEXT_MENU).
Maybe in this case, we shall "skip" the event (event.Skip()) or send a new event?
https://github.com/wxWidgets/Phoenix/blob/8908dd6c518cbddf4f7e956ab4e6f05293747d3a/wx/lib/agw/customtreectrl.py#L8191-L8194
This may be a useless comment, but what happens if you Bind() the wx.EVT_RIGHT_UP (or _DOWN) to the CustomTreeCtrl? I am assuming you will get an event to your event listener.
If you do, then you could do something like:
def OnRightDown(self, event):
pt = event.GetPosition()
item, flags = self.HitTest(pt)
if flags > 5000:
item = None
self.item = item
if item and len(self.GetSelections()) == 0:
self.SelectItem(item, True)