View Full Version : Text Field always active in window (Maya 2011)
02-06-2011, 04:08 AM
I have a script that creates an interface to select character controls. There is a text field in the UI where the user can either type or load in the name of the character rig.
This works perfectly up until Maya 2011. As soon as this text field is selected, it remains active unless you actually click out of this window. But clicking in the viewport drops the current selection, and completely defeats the purpose of my script.
I have tried making the text field uneditable, but the text field can still be selected. I can make the text field invisible, but then the user no longer has feedback to which rig is loaded...
Any other ideas? Here is a video of the UI in use, to provide some context:
02-06-2011, 03:14 PM
I never LMB-click to change focus to a viewport as, like you say, it changes selection. I'm surprised you've only just come across this before as it happens to some extent on many UIs and during many other times using Maya. I very quickly learnt to use RMB or MMB to change focus to a viewport as this doesn't affect the scene status.
However, one trick I do use on some of my own UI's is to setFocus back to the last active viewport whenever the relevent UI control changes value (or is pressed). So, for example I have a button which when pressed changes the geometry somehow, I also get it to switch focus back to the viewport so the user can press CTRL-Z to undo the operation immediately without having to manually click in the viewport if he doesn't like the result. You could do a similar thing with your input field..?
02-06-2011, 03:47 PM
I never used LMB either, I always used MMB to change focus. But in 2011, the text field is STILL active on a MMB click. RMB works though, but I don't know many animators who would want to have to RMB click to deactivate the window every time they go back and forth (which could potentially be quite frequently).
The setFocus sounds like the perfect solution, I will try that out and let you know how it goes.
Thanks so much!
02-06-2011, 04:39 PM
That got me in the right direction, thanks so much! enterCommand and setFocus did the trick!
This forum would not be the same without all your help!
06-01-2011, 12:28 AM
Sorry for the bump.
I have some buttons in my interface, just as described and in the end of the command (of the button) I added the setFocus to the last active panel (which is the viewport in most cases) but it doesn't set the focus to the viewport, instead it keeps focus on a floatField that is below the buttons. (It keeps the focus on the windows UI! Argg!)
Even if I try setting focus to modelPanel4 (instead of last active) it doesn't work. It's as if the window keeps overriding this setting. It might be just my Windows 7 settings now that I think of it, but I'll have to check tomorrow. I doubt it is though.
I'm running Maya 2011 SP1.
Thanks in advance!
I don't know how much you've altered your UI since then and if you're still working on it. But I noticed the Select, Add, Substract buttons in your UI. But you can add the functionality to the button commands that if clicked with shift it toggles the selection. Control+shift+click is add, control+shift is substract. This can be done by hooking it up to the getModifier command.
string $objects = "object"; // defined by what button pressed
// 0: None -> Replace
// 1: SHIFT -> Toggle
// 4: CTRL -> Deselect
// 5: SHIFT+CTRL -> Add
if (`getModifiers` == 0) $mode ="replace";
else if (`getModifiers` == 1) $mode ="toggle";
else if (`getModifiers` == 4) $mode ="deselect";
else if (`getModifiers` == 5) $mode ="add";
eval("select -"+$mode+" "+$objects");
Note that the above code was just outta the top of my head. If you need more info, just pm me. :)
06-02-2011, 04:35 AM
Thanks for pointing that out! I never knew something like that was possible, so I will definitely look into it. Hopefully you can find a solution to your problem.
09-30-2011, 04:59 AM
Sorry for digging up this old thread, but i'm interested to try the setFocus stuff. the problem is that i couldn't find a way yet to get the last active view panel name. I've tried searching the docs for M3dView, but could find how to retrieve the name given an M3dView node. Any clue ?
09-30-2011, 04:59 AM
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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.