Hi, I’ve made a simple UI (with cmds only) and I got a cmds.textfield where the user can insert some text. The problem is the text field is always focused when the tool is executed and I want to be deselected by default, so he won’t be editing the textfield when he actually wanted to do some operation in Maya with the tool opened.
Reading through the old posts, there was a recommendation mentioning setFocus to the last used panel, but it didn’t work. It still opens the UI with the texfield selected and active.
current_panel = cmds.getPanel( withFocus=True ) # open UI command here cmds.setFocus(current_panel)
Another extra problem is that since the textfield is focused on launching, it triggers the receiveFocusCommand flag.
A test code:
if cmds.window( 'UItest', exists=True): cmds.deleteUI('UItest', window = True) thiswindow = cmds.window('UItest', title='This is a Test', w=250, h=100, sizeable=False ) cmds.frameLayout( label='Frame', lv=False ) cmds.textField( placeholderText='This is a Test' ) cmds.setParent('..') cmds.showWindow(thiswindow)