PDA

View Full Version : AE Template buttons


VesuvianPrime
03-06-2011, 05:24 PM
Hi

I've been looking at a bunch of example Python nodes and AETemplates but I can't figure out how to create buttons in the attribute area. Currently I'm trying to make a simple file browser but I guess the same principles apply to those little checker-board texture buttons.

How would I go about doing this?

Most recent attempt:
global proc string loadPopup(){
string $loc = `fileDialog -dm "*.txt"`;
return $loc;
//yeah, this doesn't go anywhere, but I'm just trying to get the button to show right now
}

global proc AECustomNodeTemplate( string $nodeName )
{
editorTemplate -beginScrollLayout;

//File Attributes
editorTemplate -beginLayout "File Attributes" -collapse 0;
editorTemplate -addControl "input";
editorTemplate -addControl `button -label "Browse" -c "loadPopup()"`;
editorTemplate -endLayout;

AEdependNodeTemplate $nodeName;

editorTemplate -addExtraControls;
editorTemplate -endScrollLayout;
}

Azrail
03-07-2011, 09:30 AM
in order to implement custom UI controls in AETemplate you should use the -callCustom flag of the editorTemplate command.

Here is a snipped from a custom layout just to give you some idea:

global proc AEcnmAttrStrFormatTemplate(string $nodeName)
{
editorTemplate -beginScrollLayout;
editorTemplate -beginLayout "Version" -collapse false;
editorTemplate -callCustom "AEAttrStrFormatVer"
"AEAttrStrFormatVerRepl"
"pluginVersion";
editorTemplate -endLayout;
editorTemplate -endScrollLayout;
}

global proc AEAttrStrFormatVer(string $attr)
{
text -l `getAttr $attr` versionTxt;
}

global proc AEAttrStrFormatVerRepl(string $attr)
{
text -e -l `getAttr $attr` versionTxt;
}

VesuvianPrime
03-07-2011, 02:34 PM
What is the third parameter of callCustom?

Also, what does versionTxt do to the label? My MEL is very rusty.

Azrail
03-07-2011, 11:44 PM
1. The third parameter is the actual attribute name, for which the current control is created, and which would be passed as parameter to the custom procedures. You can pass as many attributes as needed.

2. 'versionTxt' is just a name for the text widget, so we can later on access it from within the *Repl procedure.

The main idea is that the first one (AEattrStrFormatVer in my example) is (sortof) used to initialize and build the controls for the current node. The second one (AEattrStrFormatVerRepl) is called on every update of the AE, and is responsible for proper updating of the UI, so here you should made any changes, which are supposed to reflect parameters on the node... hope this makes any sense :)

VesuvianPrime
03-08-2011, 01:54 AM
Thanks, you've been a massive help. I'd be completely lost without these forums.

CGTalk Moderation
03-08-2011, 01:54 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.