When I run the Python program below, EVT_RIGHT_DOWN events are caught and the mouse
position is shown in the title. When I run this program under control of another program (StoryText)
which catches both EVT_RIGHT_DOWN and EVT_CONTEXT_MENU events, the Skip call in the OnRightDown
method below results in StoryText catching an EVT_CONTEXT_MENU event, not an EVT_RIGHT_DOWN
event, even though it was the latter which caused OnRightDown to be called.
I would really like for the EVT_RIGHT_DOWN event to be propagated to StoryText. I'm guess that
EVT_CONTEXT_MENU is constructed when an EVT_RIGHT_DOWN is followed by an EVT_RIGHT_UP, so
perhaps both EVT_RIGHT_DOWN and EVT_CONTEXT_MENU are generated when this program is
run. But why is the latter propagated from a method for handling the former?
My first thought about how to approach this was to look at ALL events occurring while running this program.
I have not been able to find any info on how to do this. Older postings state that it can't be done. Has
this situation changed?
Thank you for your help.
Roger House
import wx
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, title="Right Down Example")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
class MyFrame(wx.Frame):
def __init__(self, *args, **kwargs):
super(MyFrame, self).__init__(*args, **kwargs)
self.panel = p = wx.Panel(self)
wx.StaticText(p, -1,
"Right-down on the panel to change the title", (25,25))
p.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
def OnRightDown(self, event):
pos = event.GetPosition()
mess = "Mouse is at " + str(pos)
self.SetTitle(mess)
event.Skip()
def OnExit(self, event):
self.Close()
if __name__ == "__main__":
app = MyApp(False)
app.MainLoop()