The webinar describes how to:
- work with iRidium Script in iRidium Studio;
- control the graphic part of the user's interface via iRidium Script.
Trainer: Ilya Markov, script-programmer at iRidium mobile
More about iRidium Script here http://dev.iridiummobile.net/JS_Guide/en
7. IR.AddListener(Event_Type, Reference_to_Item, function(Input_Parameters)
{
Body of Listener
});
Event_Type - the event at which the function is performed
Reference_to_Item - the reference of the item the function is assigned to
Input_Parameters - parameters giving information to the function
Body of Listerner – instructions that are done when a listener is activated
8. Types of events for system listeners
•IR.EVENT_START – Event is activated at the application launch.
•IR.EVENT_WORK – Event is activated when the application is running.
•IR.EVENT_EXIT – Event is activated when exiting the application.
•IR.EVENT_ORIENTATION – Event is activated when changing the device
orientation.
•IR.EVENT_KEYBOARD_SHOW – Event is activated when opening a keyboard.
9. IR.AddListener(Event_Type, Reference_to_Item, function(Input_Parameters)
{
Body of Listener
});
Event_Type - the event at which the function is performed
Reference_to_Item - the reference of the item the function is assigned to
Input_Parameters - parameters giving information to the function
Body of Listener – instructions that are done when a listener is activated
10. IR.AddListener(Event_Type, Reference_to_Item, function (Input_Parameters)
{
Body of Listener
});
Event_Type - the event at which the function is performed
Reference_to_Item - the reference of the item the function is assigned to
Input_Parameters - parameters giving information to the function
Body of Listener – instructions that are done when a listener is activated
11.
12. Таймеры в iRidumScript.
IR.SetTimeout(time, Name_Function); - This function is used for run a function
when the time delay
time - time delay, ms
Name_Function - name of the function that contains the command
IR.SetInterval(time, Name_Function); - This function is used to cycle with a
given recurrence interval
time - time delay, ms
Name_Function - name of the function that contains the command
13. Delete timer
IR.ClearInterval(id); - This function is used for stopping and deleting delay the
SetTimeout and SetInterval functions from the random access memory.
id - identifier of the SetTimeout or SetInterval function
15. Function to Write Data in Console
IR.Log('text');
IR.Log(Variable);
text – string
Variable – some variable
16. IR.Exit(); - This function closes the app
IR.Execute('text'); - This function is used to start other programs
IR.ShowKeyboard(value); - This function is used to show a keyboard.
17. GUI API
GUI API is a set of functions for working with graphic items in a project.
These functions let you:
Create graphic items
Delete graphic items
Refer to items and change their properties
Create listeners assigned to graphical items
Open and close pages and popups
18. IR.CreateItem(Item_Type, Item_Name, Coordinate_X, Coordinate_Y,
Item_Width, Item_Height);
This function is used to create items
Item_Type- indicate the type of the created item;
Item_Name - give the name to the item;
Coordinate_X, Coordinate_Y - initial position of the item in the working area;
Item_Width, Item_Height - width and height of the created item
19. The type of items determines what the created item will look like, that is,
defines a set of properties.
Types of items:
•Page - IR.ITEM_PAGE
•Popup - IR.ITEM_POPUP
•Button - IR.ITEM_BUTTON
•Trigger button - IR.ITEM_TRIGGER_BUTTON
•Multistate button - IR.ITEM_MUTI_STATE_BUTTON
•Up/Down button - IR.ITEM_UPDOWN_BUTTON
•Level - IR.ITEM_LEVEL
•Multistate level - IR.ITEM_MUTI_STATE_LEVEL
•EditBox - IR.ITEM_EDIT_BOX
•Virtual Key - IR.ITEM_VIRTUAL_KEY_BUTTON
•Joystick - IR.ITEM_JOYSTICK
20. IR.CreateItem(Item_Type, Item_Name, Coordinate_X, Coordinate_Y,
Item_Width, Item_Height);
This function is used for creating items
Item_Type- indicate the type of the created item;
Item_Name - give the name to the item;
Coordinate_X, Coordinate_Y - initial position of the item in the working area;
Item_Width, Item_Height - width and height of the created item
21. IR.CreateItem(Item_Type, Item_Name, Coordinate_X, Coordinate_Y,
Item_Width, Item_Height);
This function is used for creating items
Item_Type- indicate the type of the created item;
Item_Name - give the name to the item;
Coordinate_X, Coordinate_Y - initial position of the item in the working area;
Item_Width, Item_Height - width and height of the created item
22. IR.CreateItem(Item_Type, Item_Name, Coordinate_X, Coordinate_Y,
Item_Width, Item_Height);
This function is used for creating items
Item_Type- indicate the type of the created item;
Item_Name - give the name to the item;
Coordinate_X, Coordinate_Y - initial position of the item in the working area;
Item_Width, Item_Height - width and height of the created item
23. IR.CreateItem(Item_Type, Item_Name, Coordinate_X, Coordinate_Y,
Item_Width, Item_Height);
This function is used for creating items
Item_Type- indicate the type of the created item;
Item_Name - give the name to the item;
Coordinate_X, Coordinate_Y - initial position of the item in the working area;
Item_Width, Item_Height - width and height of the created item
24. IR.CreateItem(Item_Type, Item_Name, Coordinate_X, Coordinate_Y,
Item_Width, Item_Height);
This function is used for creating items
Item_Type- indicate the type of the created item;
Item_Name - give the name to the item;
Coordinate_X, Coordinate_Y - initial position of the item in the working area;
Item_Width, Item_Height - width and height of the created item
28. Functions to work with pages and popups
•IR.PagesCount – the function is used to count pages in a project
•IR.PopupsCount – the function is used to count popups in a project
•IR.CurrentPage – the function is used to get a link to the page opened at the
moment
•IR.ShowPopup – the function is used to open a popup
•IR.ShowPage – the function is used to open a page
•IR.HidePage – the function is used to close a page
•IR.HideAllPopups – the fucntion is used close all popups
•IR.HidePopup – the function is used to close a popup
29. Events for GUI Listeners
IR.EVENT_ITEM_PRESS – The listener is activated when an item is pressed
IR.EVENT_ITEM_RELEASE – The listener is activated when an item is released
IR.EVENT_ITEM_CHANGE – The listener is activated when EditBox item is
changed
IR.EVENT_MOUSE_DOWN – The listener is activated when an item is clicked on
with a mouse and the mouse is moved down
IR.EVENT_MOUSE_UP– The listener is activated when an item is clicked on
with a mouse and the mouse is moved up
IR.EVENT_MOUSE_MOVE – The listener is activated when an item is clicked on
with a mouse and the mouse is moved
30. Events for GUI API Listeners
IR.EVENT_TOUCH_DOWN – the listener is activated when an item is pressed
with a finger and the finger moves down
IR.EVENT_TOUCH_UP – the listener is activated when an item is pressed with a
finger and the finger moves down up
IR.EVENT_TOUCH_MOVE– the listener is activated when an item is pressed
with a finger and the finger moves
IR.EVENT_ITEM_SHOW– the listener is activated when a page or a popup
opens
IR.EVENT_ITEM_HIDE– the listener is activated when a page or a popup closes
New is 3.0
IR.EVENT_ITEM_END_HOLD - the listener is activated at the end of holding a graphical
item (when releasing after HOLD event)
IR.EVENT_ITEM_LOST_FOCUS - the listener is activated when any item is released
(togetether with Release or End Of Hold). The event shows lost of focus by an item
31. New in 3.0
Work with clipboard is now possible
• IR.PasteFromClipboard
• IR.GetClipboard
• IR.ShowPasteHelper
• IR.CopyToClipboard
Cloning appeared
• IR.GetItem("Page 2").GetItem("Item 1").CloneItem("Item 2");
32. New in 3.0
Local notifications IR.SendNotification
Local notification can be sent to the same iOS device where i3 pro is launches (does not work on other OS)
Syntax
IR.SendNotification(text, delay, sound_id, badge_increment_num, id)
Text – text of notification
Delay - (sec) delay in notification appearance
sound_id - id of the sound of the notification:
• 0 – no sound
• 1 – standard iOS notification sound
• 2 - standard iOS ringtone
badge_increment_num – how to increase the number of notifications over the app icon
Id – unique identifier of the notification
IR.ClearNotification – clearing notification from the app
33. New in 3.0
Global listener and subscription to any tags
In iRidium 3.0 you can subscribe to changes of ANY tag, both driver feedback or EditBox text.
//Set global listener
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(name, value)
{
IR.Log("Global Listener Activated: " + name + "tValue: " + value);
});
// Subscribe
IR.SubscribeTagChange("Drivers.KNX IP Router.Address 1");
IR.SubscribeTagChange("Drivers.AV & Custom Systems (TCP).Online");
IR.SubscribeTagChange("UI.Page 1.Item 1.Text");
IR.SubscribeTagChange("System.Time.24");
34. Sound API
•IR.PlaySound('File_Name',Slot_Number,Volume);
•File_Name - the name of sound file
•Slot_Number - The number of slot
•Volume - Volume level
•IR.StopSound('File_Name');
•File_Name - the name of sound file
•IR.StopSlot('Slot_Number');
•Slot_Number - The number of slot
•IR.StopAllSounds();
36. Event - IR.EVENT_GESTURE_BEGIN
IR.AddListener(IR.EVENT_GESTURE_BEGIN, IR.CurrentPage, function(gesture, x, y)
{
// Construction of the choice
switch(gesture)
{
case IR.GESTURE_SWIPE_LEFT:
button.Text = "Left"; // if a gesture to the left starts, the text to “Left” appears
break;
case IR.GESTURE_SWIPE_RIGHT:
button.Text = "Right"; // if a gesture to the right starts, the text to “Right” appears
break;
case IR.GESTURE_SWIPE_UP:
button.Text = "Up"; // if a gesture up starts, the text to “Up” appears
break;
case IR.GESTURE_SWIPE_DOWN:
button.Text = "Down"; // if a gesture down starts, the text to “Down” appears
break;
}
});