in the pyside docs here is what is said about using TAB for both the
default behavior (focusing on buttons) and capturing the keypress;
https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/PySide/QtGui/QWidget.html

I’m betting someone out there has reimplemented the QWidget.event method

DOCS:

Widgets that accept keyboard input need to reimplement a few more event
handlers:

PySide.QtGui.QWidget.keyPressEvent()
<https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/PySide/QtGui/QWidget.html#PySide.QtGui.PySide.QtGui.QWidget.keyPressEvent>
is called whenever a key is pressed, and again when a key has been held
down long enough for it to auto-repeat. The Tab and Shift+Tab keys are only
passed to the widget if they are not used by the focus-change mechanisms.
To force those keys to be processed by your widget, you must reimplement
QWidget.event() .
​

On Mon, Feb 22, 2016 at 2:55 PM, Martin Gunnarsson <[email protected]>
wrote:

> Nice solution!
>
> Unfortunately it overrides the default behaviour of tab in text-fields and
> the Node-Editor.
> Wonder if there is a way around that....
>
> On Friday, June 12, 2015 at 9:38:41 PM UTC+1, Mike Bourbeau wrote:
>>
>> PySide version:
>>
>> #####################################################
>> from PySide import QtCore, QtGui
>> from shiboken import wrapInstance
>> import maya.OpenMayaUI as mui
>>
>> mainWin = 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)
>> #####################################################
>>
>> On Sunday, November 11, 2012 at 10:38:42 AM UTC-5, Marcus Ottosson wrote:
>> > 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]>
>> 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]>
>> 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
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/04dd609c-91e4-45c7-bbaf-73713e14e9e3%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/04dd609c-91e4-45c7-bbaf-73713e14e9e3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABPXW4j7UN2sL5ZXA38tCiS3j2tTbMqWtD0a6WJmcttyVAdV5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to