I recently was working on some keypress event too (in c++ though but I
think the issues might be the same). One thing I realize is that keypress
event only appear when the widget is in focus. I have to explicitly set the
widget in focus when my mouse enter the widget (I am using the keypress in
combination with my mouse to activate a tool) You might want to check if
the loss of focus of your widget might be the issue.


On 12 February 2013 18:35, luiz elias <[email protected]> wrote:

> Hi all,
>
> I'm trying get a eventFilter to work and get the keyboard press event,
> it works fine for me with mouse events but I can't get the keyboard events
> to work,
> i guess I'm missing something,
> this is the far I got:
>
> import sip
> import maya.OpenMayaUI as OpenMayaUI
> from PyQt4 import QtGui, QtCore
>
> class MouseEventFilter(QtCore.QObject):
>         def eventFilter(self, obj, event):
>                 if event.type() == QtCore.QEvent.KeyPress:
>                         print "working..."
>                         return True
>                 return False
>
> view = OpenMayaUI.M3dView.active3dView()
> widget = sip.wrapinstance(long(view.widget()), QtCore.QObject)
> eventFilter = MouseEventFilter(widget)
>
> widget.installEventFilter(eventFilter)
>
> #widget.removeEventFilter(eventFilter)
>
>
> problem is that the QtCore.QEvent.KeyPress never happends =/
> any ideas why??
>
> thnaks!
>
> Luiz
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to