Button format - %nbt[button_text]
Note: The syntax for %bb - Button is very similar to %bt and %bb is usually preferred.
This format defines a button where button_text represents a standard
character string consisting of the text that is dsiplayed on the
button. The text must either be enclosed in square brackets, or an @ symbol is
used to indicate that the text is supplied as an argument. The buttons of a
dialog box are numbered from 1. The winio@ function returns the number of a
button used to close a window or zero if it was closed in some other way (this
assumes the button does not have a call-back). Button names may include the
"&" character in order to provide accelerator keys.
A grave accent (`) is used to indicate that the button is the default when the
Enter key is pressed. A default button has a slightly different appearance.
The caret character (^) may be used to define a call-back function that is
called when the user clicks on the button (or, if the button is the default
button, when the user presses the Enter key).
i=winio@('Press this to see what happens &')
c---Function to do something---
INTEGER function func()
The buttons in a format window (both %bt and %tt) are numbered from 1 in
the order in which they are defined in the format string. When the user clicks
on a button that does not have a call-back function, the format window
closes and the corresponding winio@ call returns the number of the button
pressed. For example:
outputs the value 1 if 'OK' is pressed, 2 if 'Cancel' is pressed and zero if the
window is closed without clicking on a button.
Alternatively, if a button has a call-back function that returns a negative
value, then clicking on the button causes the format window to close and
the corresponding winio@ call returns this value made positive. For example:
INTEGER FUNCTION func()
displays the value +1 if 'OK' is pressed, 2 if 'Cancel' is pressed and zero if
the window is closed without clicking on a button.
Normally a button created with %bt is permanently enabled. However,
if the tilde (~) format modifier is used then an extra INTEGER argument must be
supplied (before any call-back function). This argument provides an integer
that controls the state of the button. When this integer is zero the button is
greyed and cannot be used. When this integer is 1 the button is enabled.
Typically this control integer would be altered by code responding to another
control. For example, after a successful file-opening, a number of options
might be enabled. Note that there is no reason why the same control integer
should not control several buttons and/or menu items.
c---Only the OPEN button is initially available
i=winio@( '%^bt[Open] &',open_f)
INTEGER function open_f()
The width of the button, in average characters, can be supplied
using the parameter n (e.g. %10bt[Save]) rather than this being
determined by the width of its text. A button is created wide enough for at
least n characters (possibly more, if the font is not mono-spaced). This
enables a number of buttons of the same size to be created. %fn and %ts can be
used before %bt in order to modify the button text. %bi is used to add an icon
the a button whilst %bc is used to change its background colour.
The text on a button can be changed dynamically by calling
The text on a button will be placed on more than one line if a line feed
character (CHAR(10)) is spliced into the text at the appropriate point.