I don't know much about this particular problem, since on my OSX machine w/ Maya 2015 it does not lose focus. But you could probably install an event filter on the QApplication, to detect the ApplicationDeactivate and ApplicationActivate events. You could then handle checking if the script editor is up and on top, and if so, give it editing focus again.
Justin
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/516e6c92-4325-42b4-8f01-24f2b164a1f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin,
Thanks for replying, I will try this approach to put script editor in focus.
There is an added issue of putting the command input section of the script editor in focus.
Yury
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1B1_Zqkbwsp-%3Dk6Kf%3DDwU8fqpcuRqyHnxv%2BNN1m2r90g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSchoWTKf7Mi5xKp58rLirkB6Y-hRY5s5oYy-XE_hcpPS0A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAHUba0JoCuOefm2n9M9-3gmL-nz7ztUgz_eTLBMqhoRLKwFi-g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODgOO74jUp4iE%3DrzW6LXJcbyFTyxDCeFBpwPqmxS9QS8w%40mail.gmail.com.
Intrigued by the possibility eliminating this minor annoyance, I followed Justin’s suggestion and wrote a solution.
Run this, or put it in your userSetup.py, and it will restore focus to the Script Editor, if it is available.
from PySide import QtCore, QtGui
class RestoreScriptEditorFocus(QtCore.QObject):
def eventFilter(self, obj, event):
if event.type() != QtCore.QEvent.ApplicationActivate:
return super(RestoreScriptEditorFocus, self).eventFilter(obj, event)
script_editor = next(w for w in QtGui.qApp.topLevelWidgets() if w.objectName() == "scriptEditorPanel1Window")
script_editor.activateWindow()
return True
f = RestoreScriptEditorFocus()
QtGui.qApp.installEventFilter(f)
It’ll also “restore” focus to it, even if it wasn’t the last thing to have focus at the time of leaving the Maya window. Whether that’s a problem or not is too soon to tell, but I’ll leave the implementation for that to the reader.
Enjoy!
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGScjeg9RLFoFX7UMhwFw-gzgmSWD9KUENUaE98DdhDHiQHw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAA7%2B%3DdByo55CD%2BDqHN2Gy3FiWYcz-ZaFeHCUwSw8oi%3DQ%40mail.gmail.com.
Nice job Marcus!
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSciEK-Km-b9-fqX73W3wUvwsrnw6RBE42eE1Cy2vOsVw7w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2t1YD4AiWEvCgkXUz0zSw%3DqjHkETG9CMzsoMauBzSwGg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da5uRPfg_R6F%3DMOs6BJbsd5P4C5cuM4SevRkhBR0G1wohA%40mail.gmail.com.
Hi Eric, glad you liked it.
Thanks for posting your progress! With that in mind, I gave it another go and came up with this.
from PySide import QtCore, QtGui
class RestoreScriptEditorFocus(QtCore.QObject):
def __init__(self):
super(RestoreScriptEditorFocus, self).__init__()
QtGui.qApp.focusChanged.connect(self.on_focuschanged)
self.restore = False
def on_focuschanged(self, old, new):
self.restore = "cmdScrollFieldExecuter" in old.objectName() if old else False
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.ApplicationActivate and self.restore:
script_editor = next(w for w in QtGui.qApp.topLevelWidgets() if w.objectName() == "scriptEditorPanel1Window")
script_editor.activateWindow()
return True
else:
return super(RestoreScriptEditorFocus, self).eventFilter(obj, event)
f = RestoreScriptEditorFocus()
QtGui.qApp.installEventFilter(f)
In a nutshell, it listens for any change of focus, and records whether or not the change was from the input field of the script editor, apparently called something like “cmdScrollFieldExecuter”. Not sure how consistent this is across versions of Maya.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ff5b65a7-ef3d-4df8-885b-c150872baa24%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ff5b65a7-ef3d-4df8-885b-c150872baa24%40googlegroups.com.
----
So you don’t do anything when docked then?
I hadn’t experienced the issue when it was docked, so figured it’d be safe to simply do nothing.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/62249a4b-b686-4893-9e9e-f28352b5367e%40googlegroups.com.
# (...) try: script_editor = next(w for w in QtGui.qApp.topLevelWidgets() if w.objectName() == "scriptEditorPanel1Window"or w.accessibleName() == "Script Editor")script_editor.activateWindow() return True
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ff5b65a7-ef3d-4df8-885b-c150872baa24%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAzHUArJ7tazp_ngj%3Dyie%2BwSCxz-BjT9CyDtD61NRifFA%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ff5b65a7-ef3d-4df8-885b-c150872baa24%40googlegroups.com.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAzHUArJ7tazp_ngj%3Dyie%2BwSCxz-BjT9CyDtD61NRifFA%40mail.gmail.com.
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAC%2B%2B27KuUuvDmYOnCfwOA6QSOynseawcpGi-e3%2BL-D8E6yb-dQ%40mail.gmail.com.
MarcusBest,Hi Martin, you are most welcome!I've updated my gist to reflect the changes made in yours, and added a note about it in the new "News" section of the README. Thanks for sharing!
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAC%2B%2B27KuUuvDmYOnCfwOA6QSOynseawcpGi-e3%2BL-D8E6yb-dQ%40mail.gmail.com.
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBbj97RVbQpba4jEujdr8YX0XJQuw9AAVszXt3VaJYqPA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBbj97RVbQpba4jEujdr8YX0XJQuw9AAVszXt3VaJYqPA%40mail.gmail.com.
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAC%2B%2B27%2BUocEunTMqT4GS%3D_oEW_f%2BQBcOhbpqV1N2H9TNoEBj-g%40mail.gmail.com.