- Reference
- Lists
iRidi API. Lists (List)
Methods, events, and properties for dynamic lists that can be populated while the application runs
Events
An event is a process exposed to scripts with an identifier for monitoring.
A listener is a function that executes when its specified event occurs
Add a listener using the method IR.AddListener
IR.AddListener(event, input, action);
- event is the identifier of the event monitored by the listener
- input is an input parameter required to create the listener. If there is no parameter, specify 0
- action is an anonymous function or a reference to a declared function in which actions are performed
- pointer - optional reference to the listener's invocation context. Access it with this. The context can change while the program runs
IR.EVENT_ITEM_SELECT
Identifier of the event triggered when a list item is pressed. Obtain a List object reference using IR.GetItem().
Syntax
IR.AddListener(IR.EVENT_ITEM_SELECT, list, function, [pointer]);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("List 1") | type: object reference to the List item |
| function | function(itemID, subItemID, index) {} | type: function anonymous function or function reference |
| pointer | - | type: object pointer to the object serving as the function context (optional). |
| Output | ||
|---|---|---|
| itemID | 2 | type: number list item pressed, starting at 0 |
| subItemID | 1 | type: number list subitem pressed * 0 - the list item itself (popup); * 1...n - item on the popup, in editor display order. |
| index | 1 | type: number item index in the list, starting at 0. * When list items are deleted dynamically, itemID and index differ. |
Example
IR.AddListener(IR.EVENT_ITEM_SELECT, IR.GetItem("Page 1").GetItem("List 1"), function(itemID, subItemID, index) {
IR.Log("pressed "+itemID+" / "+subItemID);
});
IR.EVENT_LIST_ITEM_CHANGE
Identifier of the event triggered when the list is pressed, released, or moved (Press, Release, Move). It provides read/write access to all subitem properties, greatly extending list functionality. Obtain a List object reference using IR.GetItem().
Syntax
IR.AddListener(IR.EVENT_LIST_ITEM_CHANGE, list, function, [pointer]);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("List 1") | type: object reference to the List item |
| function | function(itemID, subItemID, event_type, object, index) {} | type: function anonymous function or function reference |
| pointer | - | type: object pointer to the object serving as the function context (optional) |
| Output | ||
|---|---|---|
| itemID | 2 | type: number list item pressed, starting at 0. |
| subItemID | 1 | type: number list subitem pressed * 0 - the list item itself (popup); * 1...n - item on the popup, in editor display order. |
| event_type | IR.EVENT_LIST_ITEM_PRESS | type: number event type: * IR.EVENT_LIST_ITEM_PRESS - item pressed, * IR.EVENT_LIST_ITEM_RELEASE - item released, * IR.EVENT_LIST_ITEM_MOVE - item moved, * IR.EVENT_LIST_ITEM_HOLD - item held, * IR.EVENT_LIST_ITEM_END_HOLD - item released after holding. |
| object | [Object DialogItemPrototype] | type: object reference to the changed list subitem, providing read/write access to its properties |
| index | 1 | type: number item index in the list. * When list items are deleted dynamically, itemID and index differ. |
Example
IR.AddListener(IR.EVENT_LIST_ITEM_CHANGE, list, function(itemID, subItemID, event_type, object, index) {
IR.Log("itemID " + itemID + ", subItemID " + subItemID + ", index " + index + ", object " + object.Name);
switch(event_type)
{
case IR.EVENT_LIST_ITEM_PRESS:
{
IR.Log("Pressed");
break;
}
case IR.EVENT_LIST_ITEM_RELEASE:
{
IR.Log("Relesed");
break;
}
case IR.EVENT_LIST_ITEM_MOVE:
{
IR.Log("Move");
break;
}
case IR.EVENT_LIST_ITEM_HOLD:
{
IR.Log("Hold");
break;
}
case IR.EVENT_LIST_ITEM_END_HOLD:
{
IR.Log("End Hold");
break;
}
}
});
- for the available subitem (object) properties, see iRidi API. Pages and items
- item hierarchy:
- Page / Popup - page or popup
- List - list
- ItemID - list item
- SubItemID - list subitem
- Page / Popup - page or popup
IR.EVENT_LIST_SCROLL
Identifier of the event triggered when the list is pressed, released, or moved, including programmatic movement (Press, Release, Move). It provides the current list position, scroll direction, and whether the list has reached an edge (start or end).
For a Static List, this method works only with the Center type.
Syntax
IR.AddListener(IR.EVENT_LIST_SCROLL, list, function, [pointer]);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1"). GetItem("List 1") | type: object reference to the List item |
| function | function(in_position, in_direction, in_edge) {} | type: function anonymous function or function reference |
| pointer | - | type: object pointer to the object serving as the function context (optional) |
| Output | ||
|---|---|---|
| in_position | 2 | type: number topmost (vertical list) or leftmost (horizontal list) item currently displayed (starting at 0) |
| in_direction | 3 | type: number scroll direction: 0 - right, 1 - left, 2 - down, 3 - up |
| in_edge | 1 | type: number flag indicating whether the start or end of the list has been reached: 1 - list scrolled to an edge, 0 - list not scrolled to an edge |
Example
var list = IR.GetItem("Page 1").GetItem("List 1");
IR.AddListener(IR.EVENT_LIST_SCROLL, list, function(in_position, in_direction, in_edge) {
IR.Log("POSITION " + in_position);
IR.Log("DIRECTION " + in_direction);
IR.Log("EDGE " + in_edge + "\n");
});
IR.ITEM_LISTBOX (List)
Methods for dynamic lists: graphical items of type List.
IR.CreateItem()
Create a List graphical item on the project's current page. The page can be identified using IR.CurrentPage. To create an item on a specific page, apply CreateItem() to a Page or Popup object reference obtained using IR.GetItem().
Syntax
IR.CreateItem(IR.ITEM_LISTBOX, name, X, Y, width, height);
| Input | Value | Description |
|---|---|---|
| name | "Button 1" | type: String item name, unique within the page |
| X | 30 | type: Number X coordinate |
| Y | 40 | type: Number Y coordinate |
| width | 200 | type: Number item width |
| height | 500 | type: Number item height |
| Output | ||
|---|---|---|
| Object | [Object DialogItemPrototype] | type: Object graphical object instance |
Example
IR.AddListener(IR.EVENT_START,0, function()
{
var src = IR.CreateItem(IR.ITEM_LISTBOX,"List 1",30,40,200,500);
IR.Log(src); // [Object DialogItemPrototype]
});
- To create a dialog item on a specific page, apply .CreateItem() to the page or popup reference:
var list_1 = IR.GetItem("Page 1").CreateItem(IR.ITEM_LISTBOX,"List 1",30,40,200,500);
IR.Log(list_1) // [Object DialogItemPrototype] // create list and get the link in one action
- The constructor lists only the basic properties required to create the item. All items also have a common set of additional properties and properties specific to their type. See Properties.
.CreateItem()
Create a new item within a List. Obtain a List object reference using IR.GetItem().
Syntax
list.CreateItem(item, subitem, {property: value, ...});
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object list reference |
| item | 0 | type: Number list item number, starting at 0 |
| subitem | 1 | type: Number list subitem number (item within a list entry); 0 - the entry itself, 1...n - subitems in their editor creation order |
| property | Text | type: String subitem property; the property list is the same as for a graphical item |
| value | 'text' | type: String value to write to the specified property, Number |
| Output | ||
|---|---|---|
| Object | [Object DialogItemPrototype] | type: Object graphical object instance |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var List_1 = IR.GetItem("Page 1").GetItem("List 1");
List_1.CreateItem(0, 1, {Text: "Hello"});
});
- CreateItem() is used to edit lists as well as create them. If the list item already exists, it is not deleted; only the properties specified in the method call are replaced.
- CreateItem() does not work with the new methods for working with lists.
.DeleteItem()
Delete an item from a List. Obtain a List object reference using IR.GetItem().
Syntax
list.DeleteItem(item);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object list reference |
| item | 0 | type: Number list item number, starting at 0 |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var List = IR.GetItem("Page 1").GetItem("List 1");
List.DeleteItem(0); // delete first point of list
});
.Clear()
Delete all items from a List. Obtain a List object reference using IR.GetItem().
Syntax
list.Clear();
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object list reference |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var List = IR.GetItem("Page 1").GetItem("List 1");
List.Clear(); // clear list
});
.SetPosition()
Scroll the list to the specified position. Obtain a List object reference using IR.GetItem().
Syntax
list.SetPosition(item);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object list reference |
| item | 0 | type: Number list item number, starting at 0 |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var List = IR.GetItem("Page 1").GetItem("List 1");
List.SetPosition(12); // go to point
});
To scroll the list to a specified item:
- the item must exist
- the list must be visible when the command runs; the page or popup containing it must be open
- at least 100 ms must pass after a new list item is created; a scroll command immediately after the item creation command will not run.
.SetStrictPositionByIndex()
Scroll the list to the specified position. Obtain a List object reference using IR.GetItem().
- .SetStrictPositionByIndex() is a more precise but slower implementation of .SetPosition(). It works better with differently sized list items because it accounts for each item's size. For equally sized list items, the recommended method is .SetPosition().
Syntax
list.SetStrictPositionByIndex(item);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object list reference |
| item | 0 | type: Number list item number, starting at 0 |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var List = IR.GetItem("Page 1").GetItem("List 1");
List.SetStrictPositionByIndex(12); // go to point
});
To scroll the list to a specified item:
- the item must exist
- the list must be visible when the command runs; the page or popup containing it must be open
- at least 100 ms must pass after a new list item is created; a scroll command immediately after the item creation command will not run.
Properties
Properties of List graphical items:
IR.GetItem(page/popup).GetItem(list).[property](#state)
| Property | Value" | Description |
|---|---|---|
| Template | "Popup 1" | type: string set or get the list item template, which is one of the project's popups |
| Direction | 0 | type: number set or get the list scroll direction: * 0 - vertical list * 1 - horizontal list |
| ItemsCount | 24 | type: number get the number of list items |
| Filter | "A" | type: string filter list items by name (part of the name) |
| ScrollEnabled | true | type: boolean disable manual list scrolling from the interface. The method .SetPosition continues to work. |
var list = IR.GetItem("Page 1").GetItem("List 1");
//** Template **//
IR.Log(list.Template); // "Popup 1"
list.Template = "Popup 2"; // change template if exist
//** Direction **//
IR.Log(list.Direction); // 1
list.Direction = 0; // change direction
//** ItemsCount **//
IR.Log(list.ItemsCount); // 24
//** Filter **//
list.CreateItem(0, 0, {Text: "Curriculum", Name:"Curriculum"});
list.CreateItem(1, 0, {Text: "Privacy", Name: "Privacy"});
list.Filter = "C"; // "Privacy" will be filtered out, "Curriculum" showed
IR.Log(list.Filter); // "C"
//** ScrollEnabled **//
list.ScrollEnabled = true; // list can be flipped manually
list.ScrollEnabled = false; // list cannot be flipped manually
IR.ITEM_GOOD_LIST
Methods for dynamic lists: graphical items of type Good List. Good List is a newer Listbox version with better support for displaying large numbers of items.
IR.CreateItem()
Create a Good List graphical item on the project's current page. The page can be identified using IR.CurrentPage. To create an item on a specific page, apply CreateItem() to a Page or Popup object reference obtained using IR.GetItem().
Syntax
IR.CreateItem(IR.ITEM_GOOD_LIST, name, X, Y, width, height, infinity);
| Input | Value | Description |
|---|---|---|
| name | "GList 1" | type: String item name, unique within the page |
| X | 30 | type: Number X coordinate |
| Y | 40 | type: Number Y coordinate |
| width | 200 | type: Number item width |
| height | 500 | type: Number item height |
| infinity | false | type: Boolean whether the list loops. If true, the initial list items appear after the last item |
| Output | ||
|---|---|---|
| Object | [Object DialogItemPrototype] | type: Object graphical object instance |
Example
IR.AddListener(IR.EVENT_START,0, function()
{
var GList = IR.CreateItem(IR.ITEM_GOOD_LIST, "GList 1", 20, 20, 250, 600, false);
IR.Log(GList) // [Object DialogItemPrototype]
});
- To create a dialog item on a specific page, apply .CreateItem() to the page or popup reference:
var list_1 = IR.GetItem("Page 1").CreateItem(IR.ITEM_GOOD_LIST, "GList 1", 20, 20, 250, 600);
IR.Log(list_1) // [Object DialogItemPrototype] // create list and get the link in one action
- The constructor lists only the basic properties required to create the item. All items also have a common set of additional properties and properties specific to their type. See Properties
.Adapter
An object for working with individual list items: populating them, monitoring activity, changing properties, and more.
Syntax
GList.Adapter = {}
| Input | Value | Description |
|---|---|---|
| - |
| Output | ||
|---|---|---|
| - |
Example
GList.Adapter = {
total : 8, // total number of states after the list creation
GetCount : function () {return this.total}, //makes "total" property available for external functions
GetItem : function (in_nPos) {}, // function will be called separately for each created item of list. Here you can select template of item, change their properties. in_nPos - index of list item
SetSelected : function (in_oItem, in_bSelected) {} // function will be called separately for each created item of list. It returns the link to list item as an object (popup) and the state of activity of this item - is it selected in list or not
}
Implementation example, methods and properties:
function good_list (list_item, template)
{
var l_list = list_item;
var l_oTemp = IR.GetItem(template);
l_list.GetState(0).Color = 0xFFFFFFFF;
l_list.SelectMode = 1; // 0 - cannot select, 1 - one selected item, 2 - any number of items can be marked as selected
l_list.Direction = 1; // 0 - horisontal from left to right, 1 - vertical from up to down
l_list.Adapter = {
//number of list items at start
total: 8,
//function to count the number of list items
GetCount : function ()
{
return this.total;
//use as: IR.Log("Total number of items in list = " + l_oGList.Adapter.GetCount())
},
//function to work with list items
GetItem: function(in_nPos)
{
var l_oItem = l_oTemp.Clone("" + in_nPos); // use popup as template of List item
l_oItem.GetItem("Item_name").Text = in_nPos; // display the popup position at each list item
// when press to popup in list
IR.AddListener(IR.EVENT_ITEM_RELEASE, l_oItem, function ()
{
l_list.SetSelected(l_oItem); // mark item as selected
});
// when press to some item of popup in list
IR.AddListener(IR.EVENT_ITEM_RELEASE, l_oItem.GetItem("Add"), function ()
{
l_list.Adapter.total += 1; //add one more list item
//l_list.Adapter.total -= 1; //delete the last item of list
l_list.Position = l_list.Adapter.total+1; // go to the last position of list
l_list.Update(); //update list when change the number of items in list from inside or outside
});
return l_oItem; //get object item
},
//function to work with selected items
SetSelected : function (in_oItem, in_bSelected)
{
if (in_bSelected == true)
{
//IR.Log("selected > "+in_oItem.Name);
in_oItem.GetItem("Selector").Value = 1;
} else in_oItem.GetItem("Selector").Value = 0;
}
};
return l_list;
}
var l_oGList1 = new good_list(IR.GetPage("Page 1").CreateItem(IR.ITEM_GOOD_LIST, "ConList", 16, 16, 320, 600), "Popup 1");
var l_oGList2 = new good_list(IR.GetPage("Page 1").CreateItem(IR.ITEM_GOOD_LIST, "ConList_2", 352, 16, 320, 600), "Popup 1");
/* * * * * List Of Methods
*
* l_oGList1.SetSelected(l_oItem) // mark list position as selected
* l_oGList1.Update() // update list when change the number of items
* IR.DeleteItem(l_oGList1) // remove List object
*
* l_oGList1.Adapter.GetCount() // get total number of list positions
* l_oGList1.Adapter.GetItem(4).GetItem("Item_name").Text // get list position by index
* l_oGList1.Adapter.GetItem("4").GetItem("Item_name").Text // get list position by name
* l_oGList1.Adapter.total // get or change total number of list positions
*
* l_oGList1.SelectMode // 0 - cannot select, 1- one selected item, 2 - any number of items can be marked as selected
* l_oGList1.GetState(0).Color // color of List substate
* l_oGList1.Direction // 0 - horisontal from left to right, 1 - vertical from up to down
* l_oGList1.Position // set or get the current list position
*
*****/
.SetSelected()
Mark a list item as selected. Whether an item can be selected depends on .SelectMode
Syntax
list.SetSelected(item-object);
| Input | Value | Description |
|---|---|---|
| list | IR.GetItem("Page 1").GetItem("GList 1") | type: Object list reference |
| item-object | [Object DialogItemPrototype] | type: object list item |
| Output | ||
|---|---|---|
| - |
Example
var l_oTemp = IR.GetItem("Popup 1");
l_list.Adapter = {
GetItem: function(in_nPos)
{
var l_oItem = l_oTemp.Clone("" + in_nPos); // use popup as template of List item
IR.AddListener(IR.EVENT_ITEM_RELEASE, l_oItem, function ()
{
l_list.SetSelected(l_oItem); // mark item as selected on Release
});
}
}
.Update()
Update the list. Used after changing the number of list items
Syntax
list.Update();
| Input | Value | Description |
|---|---|---|
| - |
| Output | ||
|---|---|---|
| - |
Example
var l_oTemp = IR.GetItem("Popup 1");
l_list.Adapter = {
GetItem: function(in_nPos)
{
var l_oItem = l_oTemp.Clone("" + in_nPos); // use popup as template of List item
IR.AddListener(IR.EVENT_ITEM_RELEASE, l_oItem, function ()
{
l_list.Adapter.total += 1;
l_list.Update(); // update list if number of items has been changed
});
}
}
.GetSelected()
Get a list of selected list items
Syntax
list.GetSelected();
| Input | Value | Description |
|---|---|---|
| - |
| Output | ||
|---|---|---|
| Array of selected items |
Example
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem("Item 1"), function()
{
var SelectedBuffer = l_oGList1.GetSelected();
IR.Log("SelectedBuffer = " + SelectedBuffer );
});
.ClearSelected()
Clear selection from all items
Syntax
list.ClearSelected();
| Input | Value | Description |
|---|---|---|
| - |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem("Item 2"), function()
{
l_oGList1.ClearSelected();
});
Properties
Properties of Good List graphical items:
IR.GetItem(page/popup).GetItem(good_list).property
| Property | Value | Description |
|---|---|---|
| .SelectMode | 1 | type: number control whether list items can be selected: * 0 - list items cannot be selected * 1 - 1 item can be selected * 2 - multiple items can be selected |
| .Direction | 0 | type: number set the list scroll direction: * 0 - horizontal list (left to right) * 1 - vertical list (top to bottom) |
| .Position | 10 | type: number get or change the list position |
| .GetState(0).Color | 0xFFFFFFFF | type: RGBA change the list background color |
| .Adapter.total | 24 | type: number get the number of list items |
| .Adapter.Item.Subitem.Property | - | access list item and subitem properties by addressing items by name or identifier (starting at zero), and subitems by name. For the property set, see GUI API: graphical item and state properties |
| .infinity | false | type: Boolean make the list loop (true - looping, false - not looping) |
| .StopByTap | 1 | type: number control whether touching the list stops its movement: * 0 - do not stop the list on touch * 1 - stop the list on touch |
Static List
Static List - a graphical item in which popups can be scrolled. Used to create gesture-controlled menus.
A Static List cannot be created through scripts, but popups can be added or removed and the list can be scrolled to a specified position. There is currently no function for determining its current position.
Static List object methods:
// get a link to the Static List as an object
var st_list = IR.GetItem("Page 1").GetItem("Static List Item 1")
// methods
st_list.AddPopup("Popup 1") // add a popup to the end of Static List (by name)
st_list.RemovePopup("Popup 1") // remove a popup from the Static List (by name)
st_list.SetPosition(0) // set the position of the Static List by the index from 0
st_list.Clear() // clear the Static List (romove all popups)
.AddPopup()
Add a popup to the end of a Static List. Obtain a Static List object reference using IR.GetItem().
Syntax
st_list.AddPopup(popup_name);
| Input | Value | Description |
|---|---|---|
| st_list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object Static List reference |
| popup_name | "Popup 1" | type: string name of the popup to add to the end of the list |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var st_list = IR.GetItem("Page 1").GetItem("Static List 1");
st_list.AddPopup("Popup 1");
});
.RemovePopup()
Remove a popup from a Static List by name. Access by index is not supported. Obtain a Static List object reference using IR.GetItem().
Syntax
st_list.RemovePopup(popup_name);
| Input | Value | Description |
|---|---|---|
| st_list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object Static List reference |
| popup_name | "Popup 1" | type: string name of the popup to remove from the list |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var st_list = IR.GetItem("Page 1").GetItem("Static List 1");
st_list.RemovePopup("Popup 1");
});
.SetPosition()
Move the Static List to the specified position (index). Position indexes start at zero.
Syntax
st_list.SetPosition(position);
| Input | Value | Description |
|---|---|---|
| st_list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object Static List reference |
| position | 0 | type: number position to which the list should move |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var st_list = IR.GetItem("Page 1").GetItem("Static List 1");
st_list.SetPosition(1);
});
.Clear()
Delete all items from the Static List
Syntax
st_list.Clear();
| Input | Value | Description |
|---|---|---|
| st_list | IR.GetItem("Page 1").GetItem("Item 1") | type: Object Static List reference |
| Output | ||
|---|---|---|
| - |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var st_list = IR.GetItem("Page 1").GetItem("Static List 1");
st_list.Clear();
});
Properties
Properties of Static List graphical items:
IR.GetItem(page/popup).GetItem(static_list).property
| Property | Value | Description |
|---|---|---|
| .Hit | 1 | type: number touch area and behavior settings: * 0 – Active Touch * 1 - the item handles touches anywhere, including transparent areas * 2 - the item is transparent to hit testing and does not handle touches. The object on the layer below handles the touch. The item only displays values * 3 - handles touches on any nontransparent area of the item. Touches on transparent areas are not handled (the object on the layer below handles them) |
| .ScrollEnabled | true | type: boolean disable manual list scrolling from the interface |
| .BottomIndent | 10 | type: number Set the gap between the last popup and the bottom edge of the Static List |
| .Resistance | 100 | type: number Set the popup list's scroll resistance in the Static List |
IR.ITEM_PICKER
Methods for working with a wheel: a graphical item of type Picker.
IR.CreateItem()
Create a Picker graphical item on the project's current page or popup. To create an item on a specific page, apply CreateItem() to a Page or Popup object reference obtained using IR.GetItem().
Syntax
IR.CreateItem(IR.ITEM_PICKER, name, {parameter});
| Input | Value | Description |
|---|---|---|
| name | "picker" | type: String item name, unique within the page |
| X | 30 | type: Number X coordinate |
| Y | 40 | type: Number Y coordinate |
| Min | 0 | type: Number minimum picker value |
| Max | 100 | type: Number maximum picker value |
| Template | IR.GetPopup("Template_Picker") | type: Popup Picker row template |
| Items | ["January", "February"] | type: Array picker value array (used instead of min/max) |
| Step | 10 | type: Number picker step (value increment) |
| Position | 3 | type: Number default value (starting at 0) |
| Direction | 0/1 | type: Number Picker movement direction: 0 - horizontal, 1 - vertical. |
| VisibleCount | 3, 5, 7, 9 ... | type: Number Number of visible items displayed in the picker. The number must be positive and odd. It must not exceed the number of picker items (default 3) . |
| Output | ||
|---|---|---|
| Object | [Object DialogItemPrototype] | type: Object graphical object instance |
Example
//create picker with min/max values
var picker = IR.GetItem("Page 1").CreateItem(IR.ITEM_PICKER, "picker", {
X: 55,
Y: 6,
Min: 1, // min value
Max: 31, // max value
Template: IR.GetPopup("Template Picker")
});
//create picker with array
var picker = IR.GetItem("Page 1").CreateItem(IR.ITEM_PICKER, "picker", {
X: 35,
Y: 0,
Items: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], //array
Template: IR.GetPopup("Template Picker")
});
Properties
Properties of a Picker graphical item:
IR.GetItem(page/popup).GetItem(picker).property
| Property | Value | Description |
|---|---|---|
| ItemsCount | 15 | type: number get the number of picker items |
| SelectedIndex | 2 | type: number get the index of the picker's current position |
| Position | 1 | type: number current position of picker item 1 after scrolling |
var picker = IR.GetItem("Page 1").getItem("picker");
//* * ItemsCount **//
IR.Log(picker.ItemsCount); // 15
//* * SelectedIndex **//
IR.Log(picker.SelectedIndex); //2
Getting picker values
Read a value from the Picker item's Value property.
IR.AddListener(IR.EVENT_ITEM_RELEASE, IR.GetItem(“Page 1”).GetItem("Done_Button"), function() {
var Day = parseInt(DayPicker.Value); // Day (number)
var Month = MonthPicker.Value; // Month (string)
var Year = parseInt(YearPicker.Value); // Year (number)
IR.Log("Date: " + Day + ", Month: " + Month + ", Year: " + Year); // Logging
});
Example:
IR.EVENT_PICKER_SCROLL
This method detects picker scrolling. After the required picker scrolls, another picker can be redrawn to change the number of days according to the selected month.
Syntax
IR.AddListener(IR.EVENT_PICKER_SCROLL, picker, function (in_position / Position), [pointer]);
| Input | Value | Description |
|---|---|---|
| picker | IR.GetItem("Popup 1").GetItem("midPicker"); | type: object item reference |
| function | function(in_position){} | type: function anonymous function or function reference |
| pointer | - | type: object pointer to the object serving as the function context (optional) |
| Output | ||
|---|---|---|
| in_position | 4 | type: number current position of picker item 2 after scrolling |
| Position | 3 | type: number current position of picker item 1 after scrolling |
Example
IR.AddListener(IR.EVENT_PICKER_SCROLL, MidPicker, function(in_position){
if (in_position == 3 || in_position == 5 || in_position == 8 || in_position == 10) { //левый барабан настроить на диапазон 1...30
var item_test = IR.GetPopup("Remote").GetItem("leftPicker");
IR.DeleteItem(item_test);
in_oRemotePopup.CreateItem(IR.ITEM_PICKER, "leftPicker", {
X: _Left.X - 55,
Y: _Left.Y + 6,
Min: 1, // Интервал
Max: 30, // Интервал
VisibleCount: 3, //3,5,7,...
Template: IR.GetPopup("Template Picker")
});
}
else if(in_position == 0 || in_position == 2 || in_position == 4 || in_position == 6 || in_position == 7 || in_position == 9 || in_position == 11) { //левый барабан настроить на диапазон 1...31
var item_test = IR.GetPopup("Remote").GetItem("leftPicker");
IR.DeleteItem(item_test);
in_oRemotePopup.CreateItem(IR.ITEM_PICKER, "leftPicker", {
X: _Left.X - 55,
Y: _Left.Y + 6,
Min: 1, // Интервал
Max: 31, // Интервал
VisibleCount: 3, //3,5,7,...
Template: IR.GetPopup("Template Picker")
});
}
else if(in_position == 1){ //левый барабан настроить на диапазон 1...28
var item_test = IR.GetPopup("Remote").GetItem("leftPicker");
IR.DeleteItem(item_test);
in_oRemotePopup.CreateItem(IR.ITEM_PICKER, "leftPicker", {
X: _Left.X - 55,
Y: _Left.Y + 6,
Min: 1, // Интервал
Max: 28, // Интервал
VisibleCount: 3, //3,5,7,...
Template: IR.GetPopup("Template Picker")
});
}
});
}
Example of redrawing the date picker according to the selected month: