Fix shift click not actually assigning skills

This commit is contained in:
2026-01-09 21:54:28 +01:00
parent 8800533c8a
commit aec20c1f5a
2 changed files with 9 additions and 6 deletions

View File

@@ -89,6 +89,9 @@ class ChangeAffectingSkills(ContextMenuSingle):
self.skillIds = {}
sub = wx.Menu()
# When rootMenu is None (direct menu access), use sub for binding on Windows
bindMenu = rootMenu if (rootMenu is not None and msw) else (sub if msw else None)
# Add "All" entry
allItem = wx.MenuItem(sub, ContextMenuSingle.nextID(), _t("All"))
grandSubAll = wx.Menu()
@@ -99,7 +102,7 @@ class ChangeAffectingSkills(ContextMenuSingle):
id = ContextMenuSingle.nextID()
self.skillIds[id] = (None, i, False) # None indicates "All" was selected, False = not "up"
label = _t("Level %s") % i
menuItem = wx.MenuItem(rootMenu if msw else grandSubAll, id, label, kind=wx.ITEM_RADIO)
menuItem = wx.MenuItem(bindMenu if bindMenu else grandSubAll, id, label, kind=wx.ITEM_RADIO)
grandSubAll.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
grandSubAll.Append(menuItem)
@@ -111,7 +114,7 @@ class ChangeAffectingSkills(ContextMenuSingle):
id = ContextMenuSingle.nextID()
self.skillIds[id] = (None, i, True) # None indicates "All" was selected, True = "up" only
label = _t("Up Level %s") % i
menuItem = wx.MenuItem(rootMenu if msw else grandSubAll, id, label, kind=wx.ITEM_RADIO)
menuItem = wx.MenuItem(bindMenu if bindMenu else grandSubAll, id, label, kind=wx.ITEM_RADIO)
grandSubAll.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
grandSubAll.Append(menuItem)
@@ -130,7 +133,7 @@ class ChangeAffectingSkills(ContextMenuSingle):
skillItem.SetBitmap(bitmap)
for i in range(-1, 6):
levelItem = self.addSkill(rootMenu if msw else grandSub, skill, i)
levelItem = self.addSkill(bindMenu if bindMenu else grandSub, skill, i)
grandSub.Append(levelItem)
if (not skill.learned and i == -1) or (skill.learned and skill.level == i):
levelItem.Check(True)

View File

@@ -676,9 +676,9 @@ class FittingView(d.Display):
itemContext = fullContext[1] if len(fullContext) > 1 else None
skillsMenu = ChangeAffectingSkills()
if skillsMenu.display(self, srcContext, mainMod):
# Create the submenu directly
rootMenu = wx.Menu()
sub = skillsMenu.getSubMenu(self, srcContext, mainMod, rootMenu, 0, None)
# On Windows, menu items need to be bound to the menu shown with PopupMenu
# We pass None as rootMenu so items are bound to their parent submenus
sub = skillsMenu.getSubMenu(self, srcContext, mainMod, None, 0, None)
if sub:
self.PopupMenu(sub)
return