Widget Radio

From eyeOS Wiki

Jump to: navigation, search

Contents

Introduction

As in HTML, the Radio widget consists of a list of options, giving the possibility to choose only one of them.

Widget Use

Available Generic Keys

  • horiz: specifies whether its horizontal coordinate must be taken from the left (0) or the right (1) border of its container element. Default is 0 (left).
  • vert: specifies whether its vertical coordinate must be taken from the upper (0) or from the top (1) bottom of its container element. Default is 0 (top).
  • x: specifies the horizontal displacement inside its "father" element, in pixels. Default is 10 pixels.
  • y: specifies the vertical displacement inside its "father" element, in pixels. Default is 10 pixels.
  • cent: specifies how the widget should be centered. Possible values are:
    • 0: no centering. This is the default value.
    • 1: center both horizontal and vertically.
    • 2: center horizontally.
    • 3: center vertically.
    • 4: place the widget at the horizontal and vertical center of its container element.
    • 5: place the widget at the horizontal center of its container element.
    • 6: place the widget at the vertizal center of its container element.

Please note the difference between options 1-3 and options 4-6. Options 1-3 calculate the size of the widget to ensure that the center of the widget is placed at the central point of its container, while options 4-6 set the central point coordinates as the widget's position.

  • visible: toggles the widget visibility. Possible values are 0 (hidden) or 1 (visible). Default value is 1.
  • enabled: specifies whether the widget is enabled (usable) or not. Default value is 1 (enabled), while disabled value is 0.

Specific Keys

  • checked: specifies which of the radios is checked. Default value is 0 (note that it is an index of the radio array).
  • content: as an indexed array, specifies the caption and value of the radios that conform the widget. Each element of the array is another indexed array containing a pair of values: value number 0 refers to the value of a given radio, while value number 1 specifies the shown text (caption).

Methods

 addEvent($eventName,$eventFunc,$args = )
  • Description: makes the widget execute code every time certain event is triggered.
  • Arguments:
    • eventName: the name of the JS event. Example: onchange.
    • eventFunc: the JS code to be executed.
    • args: if any, the args passed to the system.
 addOption($text,$value,$selected=0)
  • Description: adds a new option.
  • Arguments: $text is the text that will be displayed in the widget, while the value of this option is $value. $select specifies if this new option will be the selected one or not.
 check($num)
  • Description: checks an option, unchecking the previously checked radio.
  • Arguments:
    • num: index of the radio control (starting with 0) to check.
 disable()
  • Description: makes the widget unusable.
  • Arguments: none.
 enable()
  • Description: makes the widget usable.
  • Arguments: none.
 focus()
  • Description: makes this widget as the selected one.
  • Arguments: none.
 hide()
  • Description: makes the widget invisible.
  • Arguments: none.
 remove()
  • Description: removes this widget, along with its child widgets.
  • Arguments: none.
 setCss($params)
  • Description: sets CSS atributes to a widget.
  • Arguments:
    • params: specifies, in the form of an associative array, the CSS attributes to be applied. Remember that both the key and value of each element must be valid CSS properties and values respectively.
 setX($x)
  • Description: changes the horizontal position of the widget.
  • Arguments:
    • x: natural number specifying the new X coordinate.
 setY($y)
  • Description: changes the vertical position of the widget.
  • Arguments:
    • y: natural number specifying the new Y coordinate.
 uncheck($num)
  • Description: unchecks an option.
  • Arguments:
    • num: index of the radio control (starting with 0) to uncheck.
 unhide()
  • Description: makes the widget visible.
  • Arguments: none.

Can be serialized

Yes, this widget is always serialized by default. If you want to avoid it from being serialized, you can simply pass number 1 as the argument of its show() method.

Personal tools