Hello

I am trying to have a button that print "a" if the button is clicked while 
holding shift, and "b" while holding control.
This is what I have done (since it is not too long I've attached it here)

from PySide2 import QtWidgets, QtCore, QtGui

class XX(QtWidgets.QPushButton):

    def __init__(self):
        super(XX, self).__init__()
        self.setText("myCustomBtn")

    def keyPressEvent(self, event):
        if event.type() == QtCore.QEvent.KeyPress and self.isDown():
            if event.key() == QtCore.Qt.Key_Shift:
                print "a"
            if event.key() == QtCore.Qt.Key_Control and self.isDown():
                print "b"
        
        return QtCore.QObject.event(self, event)

x = XX()
x.show()

This kind of works but only if you click and keep the button down and the 
press a key y does what I want. Obviosly this is not what I want.

Any suggestions?
thanks

R




-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/4bebba97-bd1b-427f-93db-a0f1afba0eedn%40googlegroups.com.

Reply via email to