BButton¶
A BButton object draws a labeled button on-screen and responds
when the button is clicked or when it’s operated from the keyboard. If the
BButton is the default button for its window and the window is
the active window, the user can operate it by pressing the Enter
key.
BButtons have a single state. Unlike check boxes and radio
buttons, the user can’t toggle a button on and off. However, the button’s
value changes while it’s being operated. During a click (while the user
holds the mouse button down and the cursor points to the button on-screen),
the BButton’s value is set to 1
(B_CONTROL_ON). Otherwise, the value is 0
(B_CONTROL_OFF).
This class depends on the control framework defined in the
BControl class. In particular, it calls these
BControl functions:
- SetValue(). To make each change in theBControl’s value.
This is a hook function that you can override to take collateral action when the value changes.
Invoke(). To post a message each time the button is clicked or operated from the keyboard.
: You can designate the object that should handle the message by calling
BControl’s SetTarget() function
inherited from BInvoker. A model for the message is set by the
BButton constructor (or by BControl’s
SetMessage() function inherited from
BInvoker).
IsEnabled(). To determine how the button should be drawn and whether it’s enabled to post a message.
: You can call BControl’s SetEnabled() to
enable and disable the button.
A BButton is an appropriate control device for initiating an
action. Use a BCheckBox, a BPictureButton, or
BRadioButtons to set a state.