Go to: Synopsis. Return value. MEL examples.

Synopsis

addCustomPrefsTab (string $tabCreateFn, string $frameCreateFn, string $updateFn, string $holdStateFn, string $setOptVarToDefaultFn, string $title, string $name)

This proc registers a user-defined preference tab in the preferences windows of Maya.

Return value

None

Arguments

Variable Name Variable Type Description
$tabCreateFnstringThe callback function to create the tab.
$frameCreateFnstringThe callback function to create the frame layout of the tab.
$updateFnstringThe callback function to update UI elements when option vars changed.
$holdStateFnstringThe callback function to save or restore the preference setting of the tab.
$setOptVarToDefaultFnstringThe callback function to set option vars to default values.
$titlestringThe title of the tab.
$namestringThe name of the tab.

MEL examples

	global proc prefsUpdateExample()
	{
		global string $gPreferenceWindow;
		setParent $gPreferenceWindow;
		string $parent = "prefExample";
		
		if (`columnLayout -q -numberOfChildren $parent` == 0) {
			return;
		}

		setParent $parent;
		textField -e -text `optionVar -q exampleWords` words;
	}

	global proc exampleFieldChanged()
	{
		global string $gPreferenceWindow;
		if (`window -exists $gPreferenceWindow`) {
			setParent prefExample;
			if (`textField -exists words`) {
				optionVar -sv exampleWords `textField -q -text words`;
			}
		}
	}

	global proc prefsHoldCurrentStateExample(string $mode)
	{
		exampleFieldChanged();

		if ($mode == "save") {
			optionVar -sv "exampleWordsHold" `optionVar -q exampleWords`;
		} else if ($mode == "restore") {
			optionVar -sv "exampleWords" `optionVar -q exampleWordsHold`;
		} else {//	 "remove"
		//	 Remove the temporary option vars so they don't get saved out
			optionVar -remove "exampleWordsHold";
		}

		global string $gPreferenceWindow;
		if (`window -exists $gPreferenceWindow`) {
			setParent prefExample;
			if (`textField -exists words`) {
				textField -e -text `optionVar -q exampleWords` words;
			}
		}
	}

	global proc prefsCreateExample()
	{
		global string $gPreferenceWindow;
		setParent $gPreferenceWindow;
		string $parent = "prefExample";

		//	 Check to see if this has been created already.
		//	
		if (`columnLayout -q -numberOfChildren $parent` > 0) {
			return;
		}
		//	  Create the UI
		//	
		setParent $parent;
		setUITemplate -pushTemplate prefsTemplate;

		//	 This is used to force the width to fill the window
		separator -style "none" -h 1;

		string $textContent = "Hello, world!";
		if (`optionVar -exists exampleWords`) {
			$textContent = `optionVar -q exampleWords`;
		}

		textField
			-text $textContent
			-changeCommand exampleFieldChanged
			words;

		setUITemplate -popTemplate;

		exampleFieldChanged();
		prefsUpdateExample();
	}

	global proc prefsFrameLayoutCreateExample()
	{
		frameLayout -labelVisible false -borderVisible false -marginWidth 10 -marginHeight 10;
			columnLayout -adj true prefExample;
	}

	global proc prefsSetOptVarToDefault()
	{
	    optionVar -sv exampleWords "Hello, world!";
	}

	// register the new tab
	addCustomPrefsTab("prefsCreateExample",
		"prefsFrameLayoutCreateExample",
		"prefsUpdateExample",
		"prefsHoldCurrentStateExample",
		"prefsSetOptVarToDefault",
		"Example Configuration",
		"    Example");

	// unregister the tab
	deleteCustomPrefsTab("prefsCreateExample");