Works perfectly, thanks Justin!

Marcus

Den onsdagen den 7:e november 2012 kl. 18:33:11 UTC skrev Justin Israel:
>
> Check this out. You can create a QAction that is set to the Application 
> context, and then attach it to the MainWindow:
>
> ####
> from PyQt4 import QtCore, QtGui
> import sip
>
> import maya.OpenMayaUI as mui
>
> mainWin = sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QtGui.QWidget)
>
> action = QtGui.QAction(mainWin)
> action.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Tab))
> action.setShortcutContext(QtCore.Qt.ApplicationShortcut)
>
> def foo():
>     print "TAB!"
>     
> action.triggered.connect(foo)
> mainWin.addAction(action)
> ####
>
> Whenever I press TAB with the MainWindow in focus, I get the action 
> triggered. 
> Now you could either save the reference to the action and slot, and 
> disconnect/reconnect to new ones for hot key references...or..you could 
> just set this all up once and have the slot call a function on your class 
> that you can simply replace at any time. That way you never have to mess 
> with the action or original slot. You just update whatever function the 
> slot calls.
>
> -- justin
>
>
>
> On Wed, Nov 7, 2012 at 9:43 AM, Judah Baron <[email protected]<javascript:>
> > wrote:
>
>> I'm guessing you need to go higher up in the object hierarchy with the 
>> event filter. There is probably something else swallowing that event so you 
>> never receive it.
>>
>>
>> On Wed, Nov 7, 2012 at 6:28 AM, Marcus Ottosson 
>> <[email protected]<javascript:>
>> > wrote:
>>
>>> Thanks for your response. I should've mentioned, I did try installing an 
>>> event filter, but it reported events from essentially ALL keys, EXCEPT tab. 
>>> :)
>>>
>>> I'll give it another go tonight. Can you think of any other way to hook 
>>> into the tab key?
>>>
>>> --
>>> view archives: http://groups.google.com/group/python_inside_maya
>>> change your subscription settings: 
>>> http://groups.google.com/group/python_inside_maya/subscribe
>>>
>>
>>  -- 
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings: 
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to