From a4877514b4a1950ba1326f244580797d12f0a537 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Thu, 7 Oct 2010 08:00:16 +0200 Subject: [PATCH] Fix a bug where a context menu was only able to be spawned once and not reusable --- gui/contextMenu.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gui/contextMenu.py b/gui/contextMenu.py index a09096e58..09c835fb0 100755 --- a/gui/contextMenu.py +++ b/gui/contextMenu.py @@ -21,7 +21,6 @@ import wx class ContextMenu(object): menus = [] - activeMenu = {} @classmethod def register(cls): ContextMenu.menus.append(cls) @@ -29,6 +28,7 @@ class ContextMenu(object): @classmethod def getMenu(cls, selection, *contexts): menu = wx.Menu() + menu.info = {} menu.selection = selection empty = True for i, context in enumerate(contexts): @@ -44,7 +44,7 @@ class ContextMenu(object): for it, text in enumerate(texts): id = wx.NewId() item = wx.MenuItem(menu, id, text) - cls.activeMenu[id] = (m, context, it) + menu.info[id] = (m, context, it) menu.Bind(wx.EVT_MENU, cls.handler) bitmap = m.getBitmap(context, selection) @@ -61,14 +61,14 @@ class ContextMenu(object): @classmethod def handler(cls, event): - stuff = cls.activeMenu.get(event.Id) + menu = event.EventObject + stuff = menu.info.get(event.Id) if stuff is not None: m, context, i = stuff - selection = event.EventObject.selection - + selection = menu.selection if not hasattr(selection, "__iter__"): selection = (selection,) - cls.activeMenu.clear() + m.activate(context, selection, i) event.Skip()