I know others have reported alt key issues in other threads but I’m not sure this is the same issue.
I have a Panda3D window as a child of a wx frame. I’m also trying to duplicate Maya style controls, so moving the editor camera is done by holding down alt with one of the mouse buttons. If I move focus to another panel of the frame then click back on the Panda panel, I get a click captured but no modifiers captured if I am also holding down alt.
I thought maybe I could beat this by storing the alt modifier separately instead of binding to the click and modifier at the same time like this:
self.accept( 'alt-mouse1', self.SetButton )
but even using
self.accept( 'alt', self.OnAltDown )
self.accept( 'alt-up', self.OnAltUp )
doesn’t seem to give reliable results - the alt key up doesn’t seem to fire all the time.
Does anyone know how I can beat this? Thanks in advance!
The alt key is particularly troublesome because the operating system often eats it before Panda even gets a chance to see it. This is certainly true on Linux and OSX. What operating system are you running on?
Running on win7 with latest stable release of Panda.
Does it behave correctly if you leave the window unattached to the wx frame? It might be an issue with the wxFrame eating the alt events as well.
I believe so. I suppose I could bind the alt key on the wx side to toggle a flag that Panda could read, so either loop could catch the event. Seems a bit dirty to do it that way however
For anyone interested, I got around this issue by using this code:
def OnKey( evt, action='' ):
Bind this method to a wx.EVT_KEY_XXX event coming from a wx panel or
other widget, and it will stop wx 'eating' the event and passing it to
Panda's base class instead.
keyCode = evt.GetKeyCode()
if keyCode == wx.WXK_SPACE:
messenger.send( 'space' + action )
elif keyCode == wx.WXK_DELETE:
messenger.send( 'del' + action )
elif keyCode == wx.WXK_BACK:
messenger.send( 'backspace' + action )
elif keyCode == wx.WXK_ALT:
messenger.send( 'alt' + action )
elif keyCode in range( 256 ):
messenger.send( chr( keyCode ).lower() + action )
def OnKeyUp( evt ):
OnKey( evt, '-up' )
def OnKeyDown( evt ):
OnKey( evt )
and binding it to my wx.Frame (and any other panels that were catching events out of the box) like this:
self.Bind( wx.EVT_KEY_UP, OnKeyUp )
self.Bind( wx.EVT_KEY_DOWN, OnKeyDown )