1.19 class button

A button appears on the screen as a rectangle with a textual label. When the user presses the button, it will execute its associated message with the following parameters:

@receiver		The button itself

If dialog_item<-message is @default, the button will send its graphical<-name to its graphical<-device. Thus, a button named apply will invoke graphical->apply on the dialog box it is displayed on.

A button may be assigned a key-sequence to activate it. See dialog_item<-accelerator. If the dialog_item<-accelerator is "RET" the button is the default button of its device and will be highlighted. See also dialog->default_button).

A button may be assigned a popup menu using button->popup. Existence of a popup menu is indicated using a small triangle.

Bugs:

It is not possible to use an arbitrary bitmap as a button. Class label provides a (conceptually inferior) way to create active images.

See also
class click_gesture

1.19.1 Instance variables

dialog_item <- accelerator: [name]*
Activate when button->key: name is received. See window->typed for an explanation on handling accelerators in dialog windows.
button <- default_button: [bool]
Button is default button for its graphical<-device. This implies two things. First of all, if an item in the dialog is modified, the item will invoke dialog->modified_item. If the dialog finds a device<-default_button, it will make the default button graphical->active. If the RETURN key is hit in the dialog window, the default button will be button->execute’d.
button <- popup_image: image*
Indication that button has a popup menu. If present this image is painted right-of the label of the button.
button <- show_focus_border: bool
By default, the gtk and motif styles show a wide sunken border around the default button or the button holding the keyboard focus. By setting this variable to @off, this border is never painted. This is intended to deal with tightly placed buttons, buttons at the very edge of a window, etc.

The method button->label switches this flag automatically to @off if the label is set to an image.

1.19.2 Send methods

button ->compute:
Computes the graphical<-width and graphical<-height using the graphical<-name and button<-font. If the required size turns out to be smaller than button.size this size is used instead.
button ->default_button: [bool]
Inherits description from: button-default_button, button<-default_button
button ->event: event
First calls dialog_item->event. If this fails it passes the event to @_button_gesture (a click_gesture object).
button ->execute:
If dialog_item<-message is not @nil, button->execute acts as a wrapper around button->forward, dealing with the visual feedback. The visual feedback consist of switching button->status to execute and setting the busy-cursor (using display->busy_cursor).
button ->forward:
Perform associated action. The action depends in dialog_item<-message:

button ->initialise: name=name, message=[code]*, label=[name]
Create a button with the specified graphical<-name. The displayed dialog_item<-label is computed from this name using char_array<-label_name from the graphical<-name.

When the button is depressed (using the left-button) it will button->execute itself, activating the given code object.

button ->key: key=name
Normally invoked from window->typed. Key is the symbolic name of the key(-sequence) typed. If this key is equal to dialog_item<-accelerator, button->execute the button.
button ->popup: popup*
Assign button<-popup and update (add/remove) the indication on the button for the existence of a popup menu.
button ->selection: char_array|image*
Inherits description from: button<-selection
button ->status: {inactive,active,preview,execute}
Assign dialog_item<-status and redraw:
active and inactiveNormal appearance
previewInverted inside
executeGrey inside background

1.19.3 Get methods

button <-popup: create=[bool] -> popup*
Get the popup object associated with the button. If the -popup slot has value @nil and create is @on, a popup is associated with the button. This popup has one item with the following attributes:
`menu_item <-value`		<-name
`menu_item <-label`		<-label
`menu_item <-message`	message(@arg1, execute)

The message will button->execute the button when the first item is selected.

button <-selection: -> name
Equivalent to dialog_item<->label. For compatibility with older versions as well as for compatibility with other dialog_item's.