Instead of sending id, send parent item (which contains ID). This allows us to access the item to modify bitmap or any other value for it.
This commit is contained in:
@@ -67,7 +67,7 @@ class ChangeAffectingSkills(ContextMenu):
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, selection, menu, i, id):
|
||||
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||
self.context = context
|
||||
self.skillIds = {}
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ class DamagePattern(ContextMenu):
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
sDP = service.DamagePattern.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
self.fit = sFit.getFit(fitID)
|
||||
|
||||
self.patterns = sDP.getDamagePatternList()
|
||||
self.patterns.sort( key=lambda p: (p.name not in ["Uniform",
|
||||
"Selected Ammo"], p.name) )
|
||||
@@ -73,15 +77,19 @@ class DamagePattern(ContextMenu):
|
||||
item.SetBitmap(bitmap)
|
||||
return item
|
||||
|
||||
def getSubMenu(self, context, selection, menu, i, id):
|
||||
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch) # this bit is required for some reason
|
||||
|
||||
if self.m[i] not in self.subMenus:
|
||||
# if we're trying to get submenu to something that shouldn't have one,
|
||||
# redirect event of the item to handlePatternSwitch and put pattern in
|
||||
# our patternIds mapping, then return None for no submenu
|
||||
id = pitem.GetId()
|
||||
self.patternIds[id] = self.singles[i]
|
||||
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch, id=id)
|
||||
menu.Bind(wx.EVT_MENU, self.handlePatternSwitch, pitem)
|
||||
if self.patternIds[id] == self.fit.damagePattern:
|
||||
bitmap = bitmapLoader.getBitmap("state_active_small", "icons")
|
||||
pitem.SetBitmap(bitmap)
|
||||
return None
|
||||
|
||||
sub = wx.Menu()
|
||||
|
||||
@@ -116,7 +116,7 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
m.Append(id, u'─ %s ─' % text)
|
||||
m.Enable(id, False)
|
||||
|
||||
def getSubMenu(self, context, selection, menu, i, id):
|
||||
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||
self.context = context
|
||||
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
|
||||
m = wx.Menu()
|
||||
|
||||
@@ -63,7 +63,7 @@ class TargetResists(ContextMenu):
|
||||
m.Append(id, u'─ %s ─' % text)
|
||||
m.Enable(id, False)
|
||||
|
||||
def getSubMenu(self, context, selection, menu, i, id):
|
||||
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||
self.context = context
|
||||
menu.Bind(wx.EVT_MENU, self.handleResistSwitch)
|
||||
m = wx.Menu()
|
||||
|
||||
@@ -17,7 +17,7 @@ class WhProjector(ContextMenu):
|
||||
def activate(self, fullContext, selection, i):
|
||||
pass
|
||||
|
||||
def getSubMenu(self, context, selection, menu, i, id):
|
||||
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||
self.idmap = {}
|
||||
menu.Bind(wx.EVT_MENU, self.handleSelection)
|
||||
m = wx.Menu()
|
||||
|
||||
@@ -54,7 +54,7 @@ class ContextMenu(object):
|
||||
item = wx.MenuItem(menu, id, text)
|
||||
menu.info[id] = (m, fullContext, it)
|
||||
|
||||
sub = m.getSubMenu(srcContext, selection, menu, it, id)
|
||||
sub = m.getSubMenu(srcContext, selection, menu, it, item)
|
||||
if sub is not None:
|
||||
item.SetSubMenu(sub)
|
||||
|
||||
@@ -95,7 +95,7 @@ class ContextMenu(object):
|
||||
def activate(self, context, selection, i):
|
||||
return None
|
||||
|
||||
def getSubMenu(self, context, selection, menu, i):
|
||||
def getSubMenu(self, context, selection, menu, i, pitem):
|
||||
return None
|
||||
|
||||
def getText(self, context, selection):
|
||||
|
||||
Reference in New Issue
Block a user