RADIOBUTTON

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

A RADIOBUTTON is a control on a Graphical User Interface (GUI) window that represents an option a user may select. Generally, only one radio-button on a window may be selected at one time. (See below for exception).
See also CHECKBOX.

Syntax

  1. RADIOBUTTON #handle.ext, "label", [set], [reset], x, y, wide, high
  2. RADIOBUTTON #handle.ext, "label", setHandler, resetHandler, x, y, wide, high

Hints

Radiobutton Features

Setting & Resetting. Radio-buttons are set either by mouse-clicking the button, or programmatically by using the "set" command. Only one radio-button on a window may be set at any one time. (An exception is Grouped Radio-buttons, as follows.) If a radio-button is set, all other radio-buttons on the window will be automatically reset, or cleared. The command "reset" can also be used to clear a radio-button.
Changing Label. A radio-button "label" cannot be changed after the window is opened.
Grouping Radio-buttons. Sets of radio-buttons can be surrounded with a GROUPBOX and made to act as a logical unit apart from any other radio-buttons (or sets of radio-buttons) on a window. This allows your program to have more than one set of radio-buttons (options) from which your user may select. Keep in mind we are talking about exclusive options with radio-buttons; Selecting one button from a set un-selects all other buttons within a group-box.

Radiobutton Commands

The following commands (Methods) can be used with radio-buttons. See the individual pages for discussion.

Example

nomainwin

radiobutton #1.rball "Include all options", [set], [reset], 10, 150, 150, 20
radiobutton #1.rbnone "Do NOT include options", [nset], [reset], 10, 170, 150, 20

groupbox #1.gb2 "Options", 50, 10, 120, 130
statictext #1.ck1 "Lettuce", 70, 30, 100, 20
statictext #1.ck2 "Pickles", 70, 50, 100, 20
statictext #1.ck3 "Onions",  70, 70, 100, 20
statictext #1.ck4 "Cheese",  70, 90, 100, 20
statictext #1.ck5 "Tomatoes", 70, 110, 100, 20

button #1.btn1 "Place order", [quit], UL, 50, 200, 120, 25

    open "Select Options" for window as #1
    #1 "trapclose [quit]"

[set]
    #1.rball "set"   'First radiobutton is set when window opens
    wait

[nset]
    #1.rbnone "set"  'Clicking second radiobutton clears first and sets second
    wait

[reset]              'No action is needed with reset handler
    wait

[quit]
    close #1
    end

Useful Procedures

' Place a useful function or sub using this keyword here