Skip to content

Default_State - Button

Determines if the button is designated as the default-action button for its dialog

Type: Property
Access: Read/Write
Data Type: Integer
Parameters: None

Syntax

Property Integer Default_State
Access Type Syntax
Read Access: Get Default_State to IntegerVariable
Write Access: Set Default_State to IntegerVariable/Value

Description

When set to true for a button, the button is designated as the default-action button for the dialog that contains it. When the button's dialog has the focus, pressing the Enter key from within any control except another button will cause the default button's click behavior to get executed. Normally this executes the button's onClick message. A default button's border will be highlighted when it is "active" (when pressing Enter from within another object will execute the default button behavior).

Only one button within a dialog may have this property set to true. Setting this to true in one button sets this property to false in all others.

The default button assignment may be changed dynamically. In the following example, the default button is assigned to whatever button last had the focus.

Object OK_bn is a Button
    Set Label to "&Ok"
    Set Location to 115 152
    Set default_state to TRUE // we start with this as the default

    Procedure OnClick
        Send Its_OK
    End_Procedure

    Procedure OnSetFocus
        Set default_state to TRUE
    End_Procedure

End_Object

Object Cancel_bn is a Button
    Set Label to "&Cancel"
    Set Location to 115 152

    Procedure OnClick
        Send close_panel
    End_Procedure

    Procedure OnSetFocus
        Set default_state to TRUE
    End_Procedure
End_Object

When no default-action button is assigned within a dialog, pressing the Enter key from within another object will either do nothing or send the next message. This behavior is determined by the pbEnterKeyAsTabKey property within your application object.

The button class works cooperatively with its dialog container class to support default-action buttons. See the dialog property default_action_button and the procedure default_action in panel_mixin for more information.