Enable context menus on target list
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user