FutureBasic Logo

<<    Index    >> FutureBasic 5

button   statement

To create a button:
button btnNum, state, title, btnRect [,btnType]
To alter a button:
button btnNum [,[state][,[title][,btnRect]]]
To hide a button:
button -btnNum

A simplified form of the appearance button statement. The button statement puts a new button in the current output window, or alters an existing button's characteristics. After you create a button using the button statement, you can use the dialog function to determine whether the user has clicked it. You can use the button close statement if you want to dispose of the button without closing the window.
You may hide an existing button using the button statement with a negative button reference number. You can deactivate the control with either:
button 1, _grayBtn
or ...
appearance button 1, _grayBtn
When you first create a button with a given ID (in a given window), you must specify all the parameters up to and including btnRect (the btnType parameter is optional; it defaults to _push). If you later want to modify that button's characteristics, execute button again with the same ID, and specify one or more of the other parameters (except btnType, which cannot be altered). The button will be redrawn using the new characteristics that you specified; any parameter that you don't specify will not be altered.

btnNum An ID number that you assign when you create the button and that you refer to when altering or closing the button. The number you assign must be different from the btnNum of all other existing buttons, scroll bars and edit fields in the current window.
state Sets the state of the button. See button function for details.
title The text that appears inside the button (in the case of push buttons) or to the right of the button (in the case of checkboxes and radio buttons) as a string expression. As of FB 5.7.42 this can be either a Pascal or Core Foundation(CF) string. CFString use is recommended.
btnRect The button's enclosing rectangle. This can be specified in either of two ways:
(x1,y1)-(x2,y2) Coordinates of two diagonally opposite points
@rectAddr& Address of an 8 byte rectangle structure.
btnType  Specifies the type of button:
_push     (1) push button (default type)
_checkBox (2) check box
_radio    (3) radio button
_shadow   (4) framed push button
If you add the constant _useWFont to any of the above types (except _shadow) the button's title will be drawn using the window's current font ID, font size, and font style. Any subsequent change you make to the window fontID, font size, or font style will be reflected in the button's title when it is redrawn. If you don't specify _useWFont (or if the button type is _shadow) the title is drawn using the system font.

See Also:
appearance button; scroll button