From 5f697c166a7e8739f33a20b148d0896649ad4852 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 31 Jul 2019 08:57:20 +0300 Subject: [PATCH] Enable context menus on target list --- gui/builtinContextMenus/itemRemove.py | 8 +++++--- gui/graphFrame/lists.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gui/builtinContextMenus/itemRemove.py b/gui/builtinContextMenus/itemRemove.py index 4ab629557..381516435 100644 --- a/gui/builtinContextMenus/itemRemove.py +++ b/gui/builtinContextMenus/itemRemove.py @@ -25,7 +25,8 @@ class RemoveItem(ContextMenuCombined): "projectedModule", "cargoItem", "projectedFit", "projectedDrone", "fighterItem", "projectedFighter", - "commandFit", "graphFitList" + "commandFit", "graphFitList", + "graphTgtList" ): return False @@ -53,7 +54,8 @@ class RemoveItem(ContextMenuCombined): 'projectedDrone': self.__handleProjectedItem, 'projectedFighter': self.__handleProjectedItem, 'commandFit': self.__handleCommandFit, - 'graphFitList': self.__handleGraphFit} + 'graphFitList': self.__handleGraphItem, + 'graphTgtList': self.__handleGraphItem} srcContext = fullContext[0] handler = handlerMap.get(srcContext) if handler is None: @@ -158,7 +160,7 @@ class RemoveItem(ContextMenuCombined): self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitsCommand( fitID=fitID, commandFitIDs=commandFitIDs)) - def __handleGraphFit(self, callingWindow, mainItem, selection): + def __handleGraphItem(self, callingWindow, mainItem, selection): callingWindow.removeListItems(selection) diff --git a/gui/graphFrame/lists.py b/gui/graphFrame/lists.py index fb7c04f87..d34e6392e 100644 --- a/gui/graphFrame/lists.py +++ b/gui/graphFrame/lists.py @@ -224,6 +224,9 @@ class TargetList(BaseList): def __init__(self, graphFrame, parent): super().__init__(graphFrame, parent) + + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) + self.profiles = [] self.profiles.append(TargetProfile.getIdeal()) self.updateView() @@ -234,6 +237,17 @@ class TargetList(BaseList): def updateView(self): self.update(self.targets) + def spawnMenu(self, event): + selection = self.getSelectedListItems() + clickedPos = self.getRowByAbs(event.Position) + mainItem = self.getListItem(clickedPos) + + sourceContext = 'graphTgtList' + itemContext = None if mainItem is None else 'Target' + menu = ContextMenu.getMenu(self, mainItem, selection, (sourceContext, itemContext)) + if menu: + self.PopupMenu(menu) + def getListItem(self, row): if row == -1: return None