<<<<<<<<<<<<<<<<<

ui_toggle(ui) HP Widgets ui_toggle(ui)

NAME

ui_toggle

SUPERCLASS

ui

DESCRIPTION

The ui_toggle object provides an interface to the HP XwtoggleWidgetClass. It consists of a box and a label. When the toggle is clicked on, the box will be highlighted or unhighlighted to indicate the state of the toggle. Actions can be activated whenever the toggle is selected.

INSTANCE VARIABLES

label is the string that is printed on the toggle.

off_action is name of the actions object associated with the toggle. When the toggle is selected and its state toggles to off, a tick! message will be sent to the actions object.

on_action is name of the actions object associated with the toggle. When the toggle is selected and its state toggles to on, a tick! message will be sent to the actions object.

state indicates whether the toggle is on or off. The state will be set to 1 for on or 0 for off.

MESSAGES

create! creates the widget.

label? returns the value of the label instance variable.

label= sets the value of the label instance variable.

off_action? returns the value of the off_action instance variable.

off_action= sets the value of the off_action instance variable.

on_action? returns the value of the on_action instance variable.

on_action= sets the value of the on_action instance variable.

state? returns the value of the state instance variable.

state= sets the value of the state instance variable.

toggle_off sets the toggle's state to off and sends a tick! message to the on_action.

toggle_on sets the toggle's state to on and sends a tick! message to the on_action.

EXAMPLE

/* create ui and main window */

ui create!;

ui_control_panel new: my_panel parent= ui create! ;

/* create toggle and it actions */ ui_toggle new: toggle parent= my_panel label= "toggle label" on_action= on_action off_action= off_action create! ;

actions new: on_action tick_actions= `! toggle is on...';

actions new: off_action tick_actions= `! toggle is off...';

/* add exit button */

ui_button new: ebutton parent= my_panel label= "exit" action= bye_bye create! @ x : 70 @ y : 30;

actions new: bye_bye tick_actions= "ui exit!";

/* run it! */

ui on! start!;

SEE ALSO

ui, ui_button


Please send comments and suggestions to
consult@rpi.edu