Phone API Reference - UI Extended Classes - TextCycler
TextCycler
Combines a variety of core objects to create a simple control that is analgous to a web browser's radio group. Allows you to present a list of options for input. Recommended for lists with fewer than 10 options.
Require Extended Library:
var app = require('app'); app.init(); //app must be required and initialized somewhere before creating TextCyclers require('TextCycler').TextCycler; |
Class Constructor
new TextCycler
Creates a new TextCycler object.
var cyclerObj = new TextCycler(parameters); |
Initialization Parameters
Name | Required | Type | Default | Description |
---|---|---|---|---|
options | Yes | array | Each element of the option array should be an object with a key of 'value' and a key of 'display.' [{ 'value' : '1', 'display' : 'Lead off Man' }, { 'value' : '4', 'display' : 'Clean Up' }]; | |
x | No | integer | 0 | x coordinate value for top left corner. |
y | No | integer | 0 | y coordinate value for top left corner. |
width | No | integer | 150 | Width in pixels. |
height | No | integer | Text.LINE_HEIGHT | Height in pixels. |
circular | No | boolean | false | Options loop in circles. Whether or not the control should go back to the first option when the last is reached and next is pressed or when the first option is visible and previous is pressed if it should go to the end. |
prevText | No | string | Prev | Text to display on the button that takes you to the previous option. |
nextText | No | string | Next | Text to display on the button that takes you to the next option. |
initialValue | No | string | Intiial value to set the object to. If this is not provided the value defaults to the first item in the options array. The value must match the value property of one of the options. |
This extended class is not a child of base widget, so it cannot be added directly to the screen. Access the textWidget property to add or remove it from the screen. This extended class requires the 'app' library , and it must be initialized with an init function.
Methods
Name | Description |
---|---|
Sets the value of the object to one of the possible options | |
Gives the selected widget keyboard focus. Calling this method triggers the object's onFocus handler to be called, which must return true to take focus. |
Properties
Name | Description |
---|---|
textWidget | TextCycler is not a child of the base Widget so it cannot be added directly to the screen. Access the textWidget property to add or remove it from the screen. (e.g., window.add(tc.textWidget) ) Basic Example: var tc = new TextCycler(parameters); window.add(tc.textWidget); |
value | Gets the value of the currently selected option. Basic Example: var val = tcObj.value; |