Customizing Exit Button Text

AutoCAD AutoLISP & Visual LISP

 
Customizing Exit Button Text
 
 
 

For some dialog boxes, you may want to change the text of one of the exit buttons. For example, if you create a dialog box capable of destroying data, it's safer to call the button Destroy instead of OK. To do this, use the retirement_button prototype as follows:

destroy_button : retirement_button {
               label = "&Destroy";
               key = "destroy";
}

Notice the use of the ampersand (&) in the label attribute. This assigns a mnemonic to the tile. In this case the letter D is underscored in the button label and becomes the mnemonic.

NoteWhen customizing existing button subassemblies, you should obtain the proper DCL code from your base.dcl file rather than from the manual.

Once you have defined a custom exit button, you need to embed it in a subassembly that matches the appearance and functionality of the standard clusters. The following example shows the current definition of ok_cancel_help:

ok_cancel_help : column {
             : row {
                fixed_width = true;
                alignment = centered;
                ok_button;
                : spacer { width = 2; }
                cancel_button;
                : spacer { width = 2; }
                help_button;
              }
}

Create a new subassembly that replaces the ok_button with the new button as follows:

destroy_cancel_help : column {
              : row {
                 fixed_width = true;
                 alignment = centered;
                 destroy_button;
                 : spacer { width = 2; }
                 cancel_button;
                 : spacer { width = 2; }
                 help_button;
              }
}

In the standard subassembly, the OK button is the default, but this attribute wasn't added to destroy_button. Where the dialog box's action can be destructive (or very time-consuming), it is strongly recommended to make the Cancel button the default. In this case, it functions both as the default and as the Abort button:

destroy_cancel_help : column {
              : row {
                 fixed_width = true;
                 alignment = centered;
                 destroy_button;
                 : spacer { width = 2; }
                 : cancel_button { is_default = true; }
                 : spacer { width = 2; }
                 help_button;
              }
}

Because an attribute has been changed, the original Cancel button is used as a prototype, requiring a colon in front of cancel_button.

WarningWhen the Cancel button and the Default button are the same (both is_default and is_cancel are true) and you neglect to assign an action that calls done_dialog to any other button, then no other button can exit the dialog box and it will always be canceled.