Radio Buttons: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 7: Line 7:
===Syntax===
===Syntax===
[[image:Radiobuttons.png|800px]]
[[image:Radiobuttons.png|800px]]
Radio buttons can function with PRINT, INPUT, and RINPUT operations (the above syntax only shows one RINPUT FIELDS example). Each functions a bit differently:  PRINT FIELDS will print the label and button but not allow selection; INPUT FIELD will print the button for selection but not the label (and so needs a different PRINT FIELDS statement for a label; and RINPUT FIELDS displays both the button and the label and allows a selection to be made.


Specify "row, col, RADIO cols, [group][attribute] [,Fkey] [,NOWAIT]": "[^]caption"
Specify "row, col, RADIO cols, [group][attribute] [,Fkey] [,NOWAIT]": "[^]caption"
Line 22: Line 24:
program.
program.


The carrot (^) at the beginning of the caption indicates an ON (checked) setting. The carrot is not displayed.
The carrot (^) at the beginning of the caption indicates an ON (checked) setting. The carrot is not displayed.  


In the following example, RINPUT FIELDS creates two radio buttons in group 1.
In the following example, RINPUT FIELDS creates two radio buttons in group 1.
Line 45: Line 47:


<noinclude>
<noinclude>
[[Category:GUI]]
[[Category:Widget]]
</noinclude>
</noinclude>

Latest revision as of 15:17, 3 March 2014

Radio buttons allow users to select or deselect choices or options. They are functionally grouped, which means that when any entry of a group is checked, all other checked entries are unchecked.

Check Boxes work like radio buttons, but are not functionally grouped.

Each FIELD is one button.

Syntax

Radio buttons can function with PRINT, INPUT, and RINPUT operations (the above syntax only shows one RINPUT FIELDS example). Each functions a bit differently: PRINT FIELDS will print the label and button but not allow selection; INPUT FIELD will print the button for selection but not the label (and so needs a different PRINT FIELDS statement for a label; and RINPUT FIELDS displays both the button and the label and allows a selection to be made.

Specify "row, col, RADIO cols, [group][attribute] [,Fkey] [,NOWAIT]": "[^]caption"

Row and col determine where the buttons will be.

Cols is the width of the displayed caption.

Group number defaults to zero. [Group] is the number of the radio button group. Any Screen Attribute would also be placed here after the group number. The group should not be separated from the attribute by a comma.

If FKEY is specified, an FKEY interrupt is generated when the item is clicked ON or OFF.

NOWAIT denotes the G attribute, which returns control immediately to the program.

The carrot (^) at the beginning of the caption indicates an ON (checked) setting. The carrot is not displayed.

In the following example, RINPUT FIELDS creates two radio buttons in group 1. Both captions have a width of 8. If the first radio button is clicked, then an FKEY interrupt will occur, FKEY will return 10, and the value of X$ will be "^one". If the second radio button is clicked, then an FKEY interrupt will occur, FKEY will return 11, and the value of Y$ will be "^two".

00100 let X$="one" : let Y$="two"
00200 RINPUT FIELDS "1,1,radio 8,1,10;2,1,radio 8,1,11": X$,Y$
00300 PRINT FIELDS "3,1,C 30" : "FKEY value is now "&STR$(FKEY)
00400 PRINT FIELDS "4,1,C 30" : "X$="&X$&" Y$="&Y$


Output
or:

Another example:

81250     Insert_Lines=1
81260     Insert_Above$="Above"
81270     Insert_Below$="Below"
81280     if Insert_Below=1 then Insert_Below$="^"&Insert_Below$ else Insert_Above$="^"&Insert_Above$
81290     RInput #Win,Fields "2,25,Nz 3,[D];3,25,Radio 8,1[D],-1;4,25,Radio 8,1[D],-1": Insert_Lines,Insert_Above$,