thanks for reply!
do you mind to show some code?
I've tried this, but still not working..
import sip
import maya.OpenMayaUI as OpenMayaUI
from PyQt4 import QtGui, QtCore
import PyQt4
class MouseEventFilter(QtGui.QWidget):
def __init__(self, parent):
QtGui.QWidget.__init__(self, parent)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.KeyPress:
print "key press"
return False
return False
view = OpenMayaUI.M3dView.active3dView()
widget = sip.wrapinstance(long(view.widget()), QtCore.QObject)
eventFilter = MouseEventFilter(widget)
widget.installEventFilter(eventFilter)
#widget.removeEventFilter(eventFilter)
thank you!
On Tue, Feb 12, 2013 at 3:48 PM, Jiet Shern Neo <[email protected]> wrote:
> 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.
>
>
>
--
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.