Class | Package: cg | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version

## default-button

### Class

The class of the default-button control. A subclass of button.

### Control

Instance of the default-button class. Default buttons are used in modal dialogs as the OK button. This button usually appears with a double-thickness black line around it to mark it as the primary choice on a dialog.

Rename your default-buttons (Yes, Continue, Find, and Accept are all common names for them) by changing the title property.

### Why use a default button control instead of a button control?

The default button differs from the regular `button` and `cancel-button` controls by its on-change function. Default buttons have their on-change event-handler set to return-t-from-pop-up-dialog. They catch the ENTER or RETURN keystroke as a button press when they have the keyboard focus. Use this control when you want your software users to be able to click a button to continue the dialog's process by default.

### Adding a default-button control to your form

Click the default-button tool on the Component toolbar. Move the mouse cursor to the part of the form where you want to place the control, and click again. The control will appear with colored resizing handles.

### Resizing and moving the control

Controls can only be resized and moved on forms during the design stage; the size and location of everything is fixed on a running form.

Resize the control by clicking the mouse cursor and dragging one of the handles to the new size-point. Release the mouse key when you are satisfied with the new size.

Move the control by clicking anywhere on it except a resizing handle and dragging it to a new location on the form. Release the mouse key when you are ready to place the control.

### Notes

It is an error to place more than one default-button on a dialog.

Although a dialog contains a default-button, the actual default button (the one invoked if ENTER is pressed and the one surrounded by a thick black border) can be set dynamically with set-default-button.

The displayed name of the button is the value of the title property. If the wrapping property is true, the title will wrap text to a second line if necessary. If wrapping is `nil`, text that does not fit will not be displayed.

This button doesn't stay pressed in when clicked. It gives a little jump and then returns to its resting state.

### Creating an instance of a default-button control

This call to make-instance returns an instance of a default-button. Properties can be initialization keyword arguments (the keyword has the same name as the property, with a prepended colon, e.g. :left for left). Additional arguments could be provided. Their absence indicates the default value will be used.

    (make-instance 'default-button
                   :font
                    (make-font-ex nil "MS Sans Serif" 11 nil)
                   :left 321
                   :title "Default"
                   :name :default-button-1
                   :top 193)

See About how to get sample code for creating controls in cgide.htm, which explains how to use the IDE to create such code.

A diagram of window and widget classes is shown in Widget and window classes in cgide.htm.

Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version