PDA

View Full Version : Remove focus from GUI data field?


EightBit
10-23-2010, 07:49 PM
When a custom GUI Window becomes active, the first data entry field (textField, intField, etc.) grabs the focus. Is there a way to prevent that?
Thanks.

NateH
10-23-2010, 08:23 PM
use setFocus, and set the focus to something else, like a button or the window itself.

EightBit
10-23-2010, 11:50 PM
Thanks. That is helpful.
I have set it up to set the focus to a button using:
cmds.intField('numStart', w = 50, v = 1, enterCommand = 'cmds.setFocus("addParent")')

When I hit 'enter' the intField loses focus, however the "addparent" button seldom gets the focus, and if does, hitting 'enter' or 'return' does not activate the button (button press). Do you know if there is there a way to get that to work also?

ewerybody
10-26-2010, 12:05 PM
as the docs say: enterCommand (http://download.autodesk.com/us/maya/2009help/Commands/intField.html#flagenterCommand) is not executed when you enter the field but when you PRESS enter (that is NumPad enter!)

what you want is just a setFocus along with your UI creation, right?window;
columnLayout;
textField -w 200;
textField -w 200 -text "focus is here! Yay!" myTextField2;
setFocus myTextField2;
showWindow;

NaughtyNathan
10-26-2010, 12:07 PM
no eric, he wants it so that when he enters a value, it automatically sets focus to the BUTTON so he can immediately press Enter again (if desired) to activate or initiate whatever the UI does... I think :)

the problem is that buttons (in MEL UI) can't be pressed with Enter. (Space perhaps, if they have focus). I thinkl maybe he need's the prompt-dialog style of behaviour where Enter does actually accept/dismiss the dialog.. but I don't think standard (elf) UI buttons allow this behaviour.

:nathaN

CGTalk Moderation
10-26-2010, 12:07 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.