Pages and popups
Contents
- 1 Commands for Pages and Popups
- 2 Popup Creation
- 3 Page Creation
- 4 Page Deletion
- 5 Popup Deletion
- 6 Changing Page Properties
- 7 Changing Popup Properties
- 8 Counting Project Pages
- 9 Counting Project Popups
- 10 Working with Page Items
- 11 Working with Popup Items
- 12 Pressings and Gestures Made on Pages
- 13 Working with Device Orientation
- 14 Receiving the Current Page
- 15 Turning Popups
- 16 Popup Scaling
- 17 Referring to Pages
- 18 Referring to Popups
- 19 DOWNLOAD: Example of a project
DOWNLOAD: Example of a project
Commands for Pages and Popups
There are the following operations for working with project pages and popups:
- Creating pages and popups
- Changing pages and popups
- Deleting pages and popups
- Counting pages and popups
- Working with items on pages and popups
- Adding actions when activating a gesture or pressing
- Adding actions when changing the device orientation
- Turning popups
Popup Creation
To create a popup use the following command:
IR.CreateItem(IR.ITEM_POPUP, Popup_Name, CoordinateX, CoordinateY, Popup_Width, Popup_Height);
- IR.ITEM_POPUP - tell to the command to create a popup type item;
- Popup_Name - indicate the name of the popup to be created;
- CoordinateX, CoordinateY - initial popup position in the working area;
- Popup_Width, Popup_Height - popup width and height.
Example of popup creation at the application launch:
IR.AddListener(IR.EVENT_START,0,function() //Even is activated at the application launch { //Popup creation: IR.CreateItem(IR.ITEM_POPUP, Popup_Name, CoordinateX, CoordinateY, Popup_Width, Popup_Height); IR.CreateItem(IR.ITEM_POPUP, "lamps", 0, 0, 480, 100); IR.ShowPopup("lamps"); //Open the popup on the current page });
Page Creation
To create a page use the following command:
IR.CreateItem(IR.ITEM_PAGE, Page_Name, Page_Width, Page_Height);
- IR.ITEM_PAGE - tell to the command to create a page type item ;
- Page_Name - indicate the name of the page to be created;
- Page_Width, Page_Height - page width and height.
Example of page creation at the application launch::
IR.AddListener(IR.EVENT_START,0,function() //Even is activated at the application launch { //Page creation: IR.CreateItem(IR.ITEM_PAGE, Page_Name, Page_Width, Page_Height); IR.CreateItem(IR.ITEM_PAGE, "New Page", 480, 100); IR.ShowPage("New Page"); //Open the page });
Page Deletion
- under development
Popup Deletion
- under development
Changing Page Properties
To change the page properties go to the page first:
IR.GetItem("Page_Name")
- Page_Name - tell which page to go to.
Pages have their own properties and you can assign the required value to them:
IR.GetItem("Page 1").Width = 100;
- Width - indicate the "Width" property you want to work with.
Examples of changing page properties:
IR.GetItem("New Page").Width = 100; // Changing the page width IR.GetItem("New Page").Height = 100; //Changing the page height IR.GetItem("New Page").X = 100; //Changing the page X-coordinate IR.GetItem("New Page").Y = 100; //Changing the page Y-coordinate IR.GetItem("New Page").GetState(0).Border = 5; //Changing the page border IR.GetItem("New Page").GetState(0).Text = "This is new page"; //Changing the text displayed on the page IR.GetItem("New Page").GetState(0).Opacity = 200; //Changing the page opacity(0-255) //Changing the image displayed on the page //(To receive the name of the image use IntellHelp - press ctrl+space after the command IR.GetItem("New Page").GetState(0).Image =) IR.GetItem("New Page").GetState(0).Image = "pict.jpg"; //Changing the icon displayed on the page //(To receive the name of the icon use IntellHelp - press ctrl+space after the command IR.GetItem("New Page").GetState(0).Icon =) IR.GetItem("New Page").GetState(0).Icon = "pict.jpg";
Changing Popup Properties
To change the popup properties go to the popup first:
IR.GetItem("Popup_Name")
- Popup_Name - tell which page to go to.
Popus have their own properties and you can assign the required value to them:
IR.GetItem("Popup 1").Width = 100;
- Width - indicate the "Width" property you want to work with.
Examples of changing page properties:
IR.GetItem("lamps").Width = 100; // Changing the popup width IR.GetItem("lamps").Height = 100; //Changing the popup height IR.GetItem("lamps").X = 100; //Changing the popup X-coordinate IR.GetItem("lamps").Y = 100; //Changing the popup Y-coordinate IR.GetItem("lamps").GetState(0).Border = 5; //Changing the popup border IR.GetItem("lamps").GetState(0).Text = "This is new page"; //Changing the text displayed on the popup IR.GetItem("lamps").GetState(0).Opacity = 200; //Changing the popup opacity(0-255) IR.GetItem("lamps").GetState(0).Image = "pict.jpg"; //Changing the image displayed on the popup IR.GetItem("lamps").GetState(0).Icon = "pict.jpg"; //Changing the icon displayed on the popup
Counting Project Pages
To learn the number of pages in the project use the command:
IR.PagesCount.
The command gives the number and the number can be saved in the variable:
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at application launch { var count = IR.PagesCount; //The command for counting the number of pages in the project });
Counting Project Popups
To learn the number of popus in the project use the command:
IR.PopupsCount.
The command gives the number and the number can be saved in the variable:
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at application launch { var PopupsCount = IR.PopupsCount; //The command for counting the number of popups in the project });
Working with Page Items
To change the properties of the item go to the page the item is located on, then go to the item and to the property you want to change, then assign a new value to the property.
IR.GetItem("Page_Name").GetItem("Item_Name").Property = New Value;
//Search all project pages in the cycle (The cycle begins with "1" as the page with the identifier "0" is a system page and it cannot be changed) for (var i = 1; i < PagesCount; i++) { var a = IR.GetPage(i); //Assign the page identifier to the variable if (a.Name == "Page 1") //If the name of the searched page is "Page 1" { a.GetItem("Item 2").Width = 10; //Change the width of its Item 2 } }
Working with Popup Items
To change the properties of the item go to the popup the item is located on, then go to the item and to the property you want to change, then assign a new value to the property.
IR.GetItem("Popup_Name").GetItem("Item_Name").Property = New Value;
for (var i = 0; i < PopupCount; i++) //Search all project popups in the cycle { var a = IR.GetPage(i); //Assign the popup identifier to the variable if (a.Name == "Popup 1") //If the name of the searched popup is "Popup 1" { a.GetItem("Item 2").Width = 10; //Change the width of its Item 2 } }
Pressings and Gestures Made on Pages
Working with Device Orientation
Each device can take vertical (Portrait) or horizontal (Landscape) position, To receive the current device orientation use Listener:
IR.AddListener(IR.EVENT_ORIENTATION, 0, function(orientation)
- where in the variable orientation is 0 or 1 (0 - Landscape, 1 - Portrait)
IR.AddListener(IR.EVENT_ORIENTATION, 0, function(orientation) //Event is activated when changing the device orientation { IR.Log(orientation); //the device orientation(0 - Landscape, 1 - Portrait) });
Receiving the Current Page
To receive the page opened at the current moment use the command:
IR.CurrentPage;
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at the application launch { var current = IR.CurrentPage; //The command writes the identifier of the current page });
Turning Popups
To turn popups use the command:
IR.GetItem("Popup_Name").Angle = Value;
Value - the turning angle (set in degrees)
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at the application launch { IR.GetItem("Popup 1").Angle = 50; //The command for turning the popup to the input value (set in degrees) });
Popup Scaling
To scale popups use the commands:
IR.GetItem("Popup_Name").ScaleX = Value; or IR.GetItem("Popup_Name").ScaleY = Value;
Value - the percentage of scaling
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at the application launch { IR.GetItem("Popup 1").ScaleY = 0.5; //The command scales the popup by coodinate Y by 50% IR.GetItem("Popup 1").ScaleX = 0.8; //The command scales the popup by coodinate X by 80% IR.GetItem("Popup 1").ScaleY = 1.5; //The command scales the popup by coodinate Y by 150% IR.GetItem("Popup 1").ScaleX = 1.8; //The command scales the popup by coodinate X by 180% });
Referring to Pages
You can refer to any page using its name or identifier using the command:
IR.GetPage(Page_Name_or_Identifier);
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at the application launch { var MyPage = IR.GetPage("Page 1"); //Referring to the page by name var MyPage = IR.GetPage(0); //Referring to the page by identifier });
Referring to Popups
You can refer to any popup using its name or identifier using the command:
IR.GetPopup(Popup_Name_or_Identifier);
IR.AddListener(IR.EVENT_START, 0, function() //Event is activated at the application launch { var MyPopup = IR.GetPopup("Popup 1"); //Referring to the popup by name var MyPopup = IR.GetPopup(0); //Referring to the popup by identifier });