[QUOTE=Theodox;23054]I’m reasonably sure this is true - but just in case:
Is it true there’s no way to catch invidual keypresses in a maya text control (eg, a textField)? I’d like to do a progressive search filter that updates as the user types - but AFAIK there’s no way to catch individual characters as the user types: you only get change events when the user hits enter, return, or the field loses focus.
Or am I missing something?[/QUOTE]
Once you have your QtObject of the text field, you can install an eventFilter onto the textField.
In the event filter, you can process pretty much anything:
http://pyqt.sourceforge.net/Docs/PyQt4/qevent.html
qtInstanceOfTextField.installEventFilter(self)
Example of eventFilter:
def eventFilter(self, watched, event, data=''):
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_Delete:
if watched.objectName() == 'someName':
print 'Do stuff'
elif Qt.Key_Exclam <= event.key() <= Qt.Key_ydiaeresis:
if watched.objectName() == 'fileList_stringFilter_fld':
print 'Doing stuff'
elif event.key() == Qt.Key_Backspace:
if watched.objectName() == 'fileList_stringFilter_fld':
print 'Do something'
elif event.type() == Qt.CopyAction:
if watched.objectName() == 'fileActions':
print 'Doing stuff'
return False
The event filter is super useful IMO. You can implement hover, press and mouse move states through the event filter on custom widgets (just remember to set self.setMouseTracking(True))
/Christian