Материал из Module developer
Перейти к: навигация, поиск

module.CreateItem

Creating a dialogue item

Синтаксис

module.CreateItem(Type, Name, X, Y, Width, Height)

Название Пример Описание
Type IR.ITEM_BUTTON type: Number
Type of graphic item
Name "Button 1" type: string
Item name, unique for the popup
X 30 type: Number
X-axis coordinate
Y 40 type: Number
Y-axis coordinate
Width 800 type: Number
item width
Height 150 type: Number
item height
На выходе
Object [Object DialogItemPrototype] type: Object
Object of graphic item


Пример

var src = module.CreateItem(IR.ITEM_BUTTON,"Button 1",30,40,800,150); 
IR.Log(src) // [Object DialogItemPrototype]

Types of graphic items created via module.CreateItem:

  • IR.ITEM_POPUP - popup (Popup)


To create a dialogue item on a concrete popup, use CreateItem to the popup link:

    var src = module.GetPopup("Popup 1").CreateItem(IR.ITEM_BUTTON,"Button 1",30,40,800,150); 
    IR.Log(src) // [Object DialogItemPrototype]


Types of graphic items created via Popup.CreateItem:

  • IR.ITEM_BUTTON - button (Button)
  • IR.ITEM_TRIGGER_BUTTON - trigger button (Trigger Button)
  • IR.ITEM_MUTI_STATE_BUTTON - multistate button (Multistate Button)
  • IR.ITEM_UPDOWN_BUTTON - up/down Button (Up/Down Button)
  • IR.ITEM_LEVEL - level (Level)
  • IR.ITEM_MUTI_STATE_LEVEL - multistate level (Multistate Level)
  • IR.ITEM_EDIT_BOX - edit box (EditBox)
  • IR.ITEM_VIRTUAL_KEY_BUTTON - virtual key (Virtual Key)
  • IR.ITEM_JOYSTICK - joystick (Joystick)
  • IR.ITEM_PICKER - item picker



Creating IR.ITEM_PICKER has the following construction:

Синтаксис

Popup.CreateItem(Type, Name, Parameters)

Название Пример Описание
Type IR.ITEM_PICKER type: Number
Type of graphic item
Name "Picker 1" type: string
Item name, unique for popup
Parameters - type: Object
There are two variants of parameters. First: {X: Number, Y: Number, Min: Number, Max: Number, VisibleCount: Number, Template: Popup}, Second: {X: Number, Y: Number, Items: Array, VisibleCount: Number, Template: Popup
}
На выходе
Object [Object DialogItemPrototype] type: Object
Object of graphic item


Пример

var Template = module.GetPopup("Template");
var Popup = module.GetPopup("Popup 1");
//Creating  IR.ITEM_PICKER с Parameters v1
var Picker_1 = Popup.CreateItem(IR.ITEM_PICKER, "Picker_1", {
	X: 30, //X-axis coordinate 
	Y: 40, //Y-axis coordinate 
	Min: 1, //picker initial value
	Max: 31, //picker final value
	VisibleCount: 3, //Number of displayed values
	Template: Template //Template for picker
});
var Value = Picker_1.Value; //getting picker values 
Picker_1.Position = 10; //setting picker position 
//Creating IR.ITEM_PICKER with Parameters v2
var DayOfWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
var Picker_2 = Popup.CreateItem(IR.ITEM_PICKER, "Picker_2", {
	X: 30,
	Y: 40,
	Items: DayOfWeek, //values array
	VisibleCount: 3,
	Template: Template
});
var Value = Picker_2.Value; //getting picker value
Picker_2.Position = 3; //setting picker position

VisibleCount field must contain only odd numbers!