PDA

View Full Version : How do you have a Button Execute a Procedure


suspend
11-19-2010, 02:30 PM
Ok How do you get a button to run a procedure and pass it field values...What I have just doesn't work, can someone red pen this? Thank you in advance

{
$win = `window`;

// define the layout of controls added
// to the window.
columnLayout;
$firstFrame = intField;
$midFrame = intField;
// create a command to delete the window
$command = ("deleteUI " + $win);

$deletekeys = ("framecopy" +($firstFrame));
// create a couple of buttons

button -label "Delete Keys" -command $deletekeys;
button -label "quit" -command $command;

// show the window we last created
showWindow;
};



global proc framecopy( int $frame )

{
currentTime $frame ;
timeSliderCopyKey;
currentTime 298 ;
timeSliderPasteKey false;

};

NaughtyNathan
11-19-2010, 03:08 PM
your syntax is wrong here:
$firstFrame = intField;to "capture" the result of a function/command you use `backticks`:
$firstFrame = `intField`;additionally, the result from a UI command is simply the NAME of the control you created. In other words, your STRING variable $firstFrame contains: "intField1".
To query the values of UI controls you have to query them by name e.g.:
string $inputBox = `intField`;
button -label "Delete Keys" -command ("frameCopy `intField -q -v "+$inputBox+"`");
there may be some other stuff wrong in your code, but this is the main issue. Have a read of the Maya Help > User Guide > General > MEL > Creating Interfaces docs, they go through all this.
:nathaN

suspend
11-19-2010, 03:51 PM
You are quite the prolific replier, thank you very much - also thenks, for all the responses to others I lurk off of.

Nyro
11-19-2010, 06:40 PM
sneeky doubleposter.

I replied in the thread in the main Maya forum you posted.

Nathan, feel free to drop by as well :)

CGTalk Moderation
11-19-2010, 06:40 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.