Closed theodox closed 8 years ago
Totally. I ran into this problem for a project I am working on and could not find a native Maya ELF way to do this. PySide/PyQt might be the way to go. I am planning to fiddle with this a bit when I get home.
I know that mGui tries to keep PySide/PyQt based hacking away (from the readme.md), so I was looking at alternative methods in the API. Do you think we can somehow use MDeviceState ( http://download.autodesk.com/us/maya/2010help/API/class_m_device_state.html ) and/or MPxMidiInputDevice ( http://download.autodesk.com/us/maya/2010help/API/class_m_px_midi_input_device.html ) to gain access to the keyboard after the textField recieves focus until it is tabbed out/enter is pressed/focus is lost?
hmm, that's an interesting idea. It would be better than the Pyside version if it existed in older mayas....
OTOH, as long as the GUI is inside a bindingcontext it turns out you can force and update properly just by calling update_bindings. If there's a close button, it's the window can be set to retain=True so it doesn't die when the close button is hit - the bindings will still be working. However there's still no notification that the window was 'closed' when retain is on :(
There's an experimental fix in the remove_keys
branch
Maya's text field does not send a notification on content changes - only for enter/return key or when the user changes focus. This means that callbacks on changes to text content don't get fired if the user does not tab/return out of the field. So, if you have a button that closes your window, and are relying on bindings to get your text fields, you will never be notified that the text in a text field has changed if you ciick the window close button or another piece of UI that tries to close the window.
AFAIK the only way around this would be to use PySide to grab the underlying QT widget and manually hook the appropriate event (the QT widget should have more events than the Maya wrapper around it does).
Thoughts? Suggestions?