If this is on Linux, what is your mouse focus policy in the OS? Is it click to focus?
On Wed, Feb 13, 2013 at 11:01 AM, Justin Israel <[email protected]>wrote: > Sent too quickly... > I meant to say that just calling setFocus() still seems to require a click > before it really grabs the keyboard: > > http://pastebin.com/KfpjXABm > > import sip > import maya.OpenMayaUI as OpenMayaUI > from PyQt4 import QtGui, QtCore > > class MouseEventFilter(QtCore.QObject): > def eventFilter(self, obj, event): > typ = event.type() > if typ == event.Enter or typ == event.MouseButtonPress: > print "mouse enter" > obj.setFocus() > elif typ == event.Leave: > print "mouse leave" > obj.clearFocus() > elif typ == event.KeyPress: > print "working..." > return True > return False > > view = OpenMayaUI.M3dView.active3dView() > widget = sip.wrapinstance(long(view.widget()), QtCore.QObject) > eventFilter = MouseEventFilter() > widget.installEventFilter(eventFilter) > > # remove > widget.removeEventFilter(eventFilter) > eventFilter.deleteLater() > > > On Feb 14, 2013, at 7:56 AM, Justin Israel wrote: > > I got it working after a click occurs in the viewport, but not when you > just try and call setFocus() on the widget. > > > On Feb 13, 2013, at 11:35 PM, luiz elias wrote: > > it works fine if I install the eventFilter on the main window, but I can't > find a way to set keyboard focus for the QGLWidget. > > thanks! > > > > -- > 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. > > > -- Where we have strong emotions, we're liable to fool ourselves - Carl Sagan -- 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.
