No problem. Actually I think it might have been the spacebar that is OSX specific, where it does not trigger buttons as it does on windows/linux.
Either way... yay! On Thu, Aug 30, 2012 at 6:22 PM, Jesse Kretschmer <[email protected]> wrote: > Using QShortcut worked wonderfully. I was considering setting up the > keypress for the windows, but I like this better. > > Also, I am running on windows 7. > > Thanks for the helpful answer. > Cheers! > jesse > > On Thu, Aug 30, 2012 at 6:11 PM, Justin Israel <[email protected]> > wrote: >> >> Just to add...I believe this may only be an OSX issue because of how >> the window manager directly handles buttons natively. Are you running >> OSX by chance? >> >> >> On Thu, Aug 30, 2012 at 6:07 PM, Justin Israel <[email protected]> >> wrote: >> > While setting the default on the button does give it focus, it still >> > doesn't make the key connection to click the button. >> > Here are two different ways to accomplish it. >> > >> > The first is to just create two QShortcut objects, and connect their >> > keys to the clickedB slot: >> > >> > def __init__(self): >> > ... >> > shortcut = >> > QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return), >> > self.buttonB) >> > shortcut.activated.connect(self.clickedB) >> > >> > shortcut = >> > QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Enter), self.buttonB) >> > shortcut.activated.connect(self.clickedB) >> > >> > Or if you wanted the entire window to have the enter/return key >> > trigger the button, you could watch the key press events and then call >> > the button: >> > >> > def keyPressEvent(self, event): >> > if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): >> > self.buttonB.click() >> > super(testWindow, self).keyPressEvent(event) >> > >> > >> > >> > On Thu, Aug 30, 2012 at 5:35 PM, Jesse Kretschmer <[email protected]> >> > wrote: >> >> Howdy, >> >> I'm just starting to play with PySide in Maya. I want to create a >> >> window >> >> with a button that gets clicked if the enter/return key is hit. >> >> >> >> I'm trying with self.myButton.setAutoDefault(True) as well as >> >> self.myButton.setDefault(True). >> >> >> >> Using these methods causes my button to have a darker border than >> >> regular >> >> buttons, but the enter key does nothing. I suspect maya is blocking >> >> this >> >> signal. The shortcut keys assigned to the buttons work as expected, I >> >> don't >> >> believe it is a window focus issue. >> >> >> >> Does anyone know how to capture the enter key for a custom window? >> >> >> >> Here's a full example: >> >> http://pastebin.com/mDGJkH3H >> >> >> >> Cheers, >> >> jesse >> >> >> >> -- >> >> 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 -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
