PDA

View Full Version : custom script editor


ManuelM
10-03-2009, 12:43 AM
I hope someone will be able to help me with this. I've been searching the forum and it seems the cmdScrollFieldExecuter is one of the less discussed things around here.

So basically I'm looking for suggestions on how to best solve the following problem:

-Build a custom script editor (I know how to do that via cmdScrollFieldExecuter)


global proc testWin()
{
string $win = "testWin";

if (`window -q -ex $win`)
{
deleteUI $win;
} else{

window -w 300 -h 400 $win;
columnLayout -adjustableColumn true;
string $sfe = `cmdScrollFieldExecuter -h 400 "newScriptEditor"`;

showWindow $win;
}
}

testWin();


-Type some text into the window
-Close the window

Now the next time I run that script, I want the stuff that I've just typed to still be there just like in Maya's default scriptEditor. I've looked through scriptEditorPanel.mel to see how they do it but what exactly is going on there super confusing to me.
I'll be very thankful for any suggestions.

Cheers,
M.

goleafsgo
10-05-2009, 12:53 PM
The big difference between the normal script editor and yours is that the normal one is a scriptedPanel and yours is just a window/layout/control.

scriptedPanels have their UI kind of popped in and out of their parent layouts so it doesn't really get deleted when you close the window its in. That's why the text stays in them as you open/close it. Then there is some extra code which runs when Maya is shutting down to copy out the text to a temp file in your pref's area and it's read back in when Maya starts up again.

You can take a look at the example in the command doc's for scriptedPanelType to get an idea about how they work.

ManuelM
10-05-2009, 01:58 PM
ok great. what I'm doing so far is to create the window with the -retain flag, so I guess now when I close it it's not really being deleted as when I call the script again the next time, the content is still there. I'd still like to be able to save a backup of what the user has typed to a file. I guess that's what the -storeContents and -loadContents could ne useful for.

Thanks for your reply goleafsgo!
:)

goleafsgo
10-05-2009, 02:24 PM
What you should probably do is create a scriptJob when you create your window for the first time that listens for the "quitApplication" event and do your save there. Also when you're creating it for the first time you could check to see if your file exists and load it.

CGTalk Moderation
10-05-2009, 02:24 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.