HTBasic Help
×
Menu
Index

ASSIGN TO WIDGET

Creates or destroys widgets.
 
ASSIGN @widget-handle TO WIDGET widget-type$;[PARENT@widget-handle,] SET (widget-attrib [,widget-attrib ])
ASSIGN @widget-handle TO *
 
Example:          ASSIGN TO WIDGET.BAS
 
Where:
widget-handle = object name of the widget (similar to a variable name)
widget-type$ = String variable or literal containing the type of widget to be created or destroyed
widget-attrib = attrib-type$:value
  attrib-type$ = string variable or literal containing the attribute type
  value = numeric variable or constant containing the attribute value
 
 
 
Usage:
ASSIGN @Panel TO WIDGET "PANEL";SET("X":5,"Y":5, "WIDTH":500,"HEIGHT":350,"TITLE":"Engine Monitor")
ASSIGN @Strip TO WIDGET "STRIPCHART";PARENT@Main1,SET ("X":5,"Y":5,"WIDTH":350,"HEIGHT":250,"SHOW NUMBERING":0)
ASSIGN @strip TO * !Destroy the @Strip widget
 
Description:

Assigning Widget Handles

The ASSIGN TO WIDGET statement creates a new widget and ASSIGNs it a "widget-handle" (equivalent to an I/O path). The widget handle can then be referenced in STATUS, CONTROL, and ON EVENT, to control the appearance and behavior of the widget. The widget can also be destroyed with ASSIGN@widget-handle TO *, where "*" essentially means NOTHING.
 
The ASSIGN TO WIDGET statement is therefore used to:
 

PARENT Option

If no parent is specified when creating a new-widget, the widget is said to be a "level-0" widget.  Level-0 is a primary or main widget that is not contained within another widget, and may exist at any place in the HTBasic output window.  The X and Y coordinates of the widget are relative to the upper-left corner of the HTBasic output window.
 
Only level-0 widgets may include a title bar, a resize border, and a system menu.  The title bar and resize border allow you to change the position and size of the widget.  If a parent is specified, the new widget will be treated as a "child widget" of its parent.  If you attempt to move a child widget outside the border of the parent widget, the child will be "clipped" at the parent widget’s borders.  The child widget’s X and Y coordinates are relative to the upper-left corner of the parent widget.
 
Not all widgets can be parents, and not all widgets can be children of parent widgets.
 

TRANSIENT Option

The TRANSIENT option is used primarily when the resulting widget is to function as a dialog.  If you create a widget using the TRANSIENT option, other non-transient widgets cannot be placed on top of the widget.
 
If the transient widget has a parent, the transient widget is not restricted to lie within the bounds of its parent as are other child widgets.  Visually, the transient widget appears to be a special type of level-0 widget.
 

SET Option

All widgets have a variety of attributes that control their appearance and behavior.  You can initialize the values of these attributes at the time of creation of the widget by using the SET option.
 
Attributes are either scalar (may contain a singel value) of vector (may be assigned an array of values) and have value of either numeric or string type.
 

Shorthand: Array Assignment of Attributes

Rather than a list of individual attribute:value pairs in the SET option of the ASSIGN statement, you can use a single pair of arrays- a string array containing all the attribute names, and a numeric array of the same size containing all the corresponding attribute values. Elements of the string array that contain nothing will be ignored.
 
For example:
 
Attribs$(1) = "X"
Attribs$(2) = "Y"
Attribs$(3) = "WIDTH"
Attribs$(4) = "HEIGHT"
Values(1) = 5
Values(2) = 5
Values(3) = 500
Values(4) = 300
ASSIGN @Panel TO WIDGET "PANEL";SET(Attrib$(*):Values(*))
 
See Also: