From caef752a740a62612d2c5dcafde8f534d24989fe Mon Sep 17 00:00:00 2001 From: burnsypet Date: Wed, 16 Aug 2017 22:54:32 +0100 Subject: [PATCH] Bind contextHandler to children of contentPanel Changes to statsPane.py: Added new method applyBinding which loops through all the children of the contentPanel passed to it and binds contextHandler to each of them Changes to miningyieldViewFull.py: Call to new method applyBinding --- gui/builtinStatsViews/miningyieldViewFull.py | 2 ++ gui/statsPane.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gui/builtinStatsViews/miningyieldViewFull.py b/gui/builtinStatsViews/miningyieldViewFull.py index be69be316..7a9808284 100644 --- a/gui/builtinStatsViews/miningyieldViewFull.py +++ b/gui/builtinStatsViews/miningyieldViewFull.py @@ -122,6 +122,8 @@ class MiningYieldViewFull(StatsView): self.parent.views.append(view) # Get the TogglePanel tp = self.panel.GetParent() + # Bind the new panel's children to allow context menu access + self.parent.applyBinding(self.parent, tp.GetContentPane()) tp.SetLabel(view.getHeaderText(fit)) view.refreshPanel(fit) diff --git a/gui/statsPane.py b/gui/statsPane.py index ce09e2e62..c970ef672 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -113,7 +113,7 @@ class StatsPane(wx.Panel): view.populatePanel(contentPanel, headerPanel) tp.SetLabel(view.getHeaderText(None)) view.refreshPanel(None) - + contentPanel.Bind(wx.EVT_RIGHT_DOWN, self.contextHandler(contentPanel)) for child in contentPanel.GetChildren(): child.Bind(wx.EVT_RIGHT_DOWN, self.contextHandler(contentPanel)) @@ -143,3 +143,10 @@ class StatsPane(wx.Panel): event.Skip() return handler + + @staticmethod + def applyBinding(self, contentPanel): + pyfalog.debug("Attempt applyBinding to children of {0}", contentPanel.viewName) + for child in contentPanel.GetChildren(): + child.Bind(wx.EVT_RIGHT_DOWN, self.contextHandler(contentPanel)) + \ No newline at end of file