The mel command confirmDialog brings
up a simple little yes/no; ok/cancel type of dialog box. Simply
check the return argument from the command to see what was chosen.
{
// create a confirm dialog with a yes and no button. Specif
$response = `confirmDialog -title "Confirm"
-message "Yes or No? It's your choice..."
-button "Yes"
-button "No"
-defaultButton "Yes"
-cancelButton "No"
-dismissString "No"`;
// check response if( $response == "Yes" ) {
print("User says yes\n");
} else if( $response == "No" ) {
print("User says no\n");
}
}
Font Dialog
The mel command fontDialog allows
you to request a specific font. It is my understanding that
this only works on Windows, but i shall check later. The returned
argument from font dialog is the name of the font selected.
{
// create a font dialog and store the chosen font
// in the $font_name variable
$font_name = `fontDialog`;
// print selected fontprint( "font selected \"" + $font_name + "\"\n" );
}
Prompt Dialog
The prompt dialog in mel allows you to bring up a small window
into which can be used to request a specific value from the
user.
{
string $text;
// create a prompt dialog to request the users namestring $result = `promptDialog
-title "Hello Window"
-message "Enter Name:"
-button "OK" -button "Cancel"
-defaultButton "OK" -cancelButton "Cancel"
-dismissString "Cancel"`;
// if OK pressedif ($result == "OK") {
// query the entry typed by the user
$text = `promptDialog -query -text`;
print("HELLO to "+ $text +"\n");
}
else {
print("fine. I won't say hello then :(\n");
}
}