DgsGetChild: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} This function returns one of the child dgs elements of a given parent dgs element. The child dgs element is selected by its index (0 for the fir...")
 
Line 18: Line 18:
DGS = exports.dgs
DGS = exports.dgs


parent = DGS:dgsDxCreateWindow(200,100,400,400,"DGS Parent Window",false) --Create a window
parent = DGS:dgsCreateWindow(200,100,400,400,"DGS Parent Window",false) --Create a window
child1 = DGS:dgsDxCreateLabel(10,0,380,20,"",false,parent) --Create child 1
child1 = DGS:dgsCreateLabel(10,0,380,20,"",false,parent) --Create child 1
child2 = DGS:dgsDxCreateLabel(10,20,380,20,"",false,parent) --Create child 2
child2 = DGS:dgsCreateLabel(10,20,380,20,"",false,parent) --Create child 2
child3 = DGS:dgsDxCreateLabel(10,40,380,20,"",false,parent) --Create child 3
child3 = DGS:dgsCreateLabel(10,40,380,20,"",false,parent) --Create child 3
child4 = DGS:dgsDxCreateLabel(10,60,380,20,"",false,parent) --Create child 4
child4 = DGS:dgsCreateLabel(10,60,380,20,"",false,parent) --Create child 4


--Set a random number to a random child.
--Set a random number to a random child.
Line 28: Line 28:
local child = DGS:dgsGetChild(parent,math.random(1,4))
local child = DGS:dgsGetChild(parent,math.random(1,4))
if isElement(child) then
if isElement(child) then
DGS:dgsDxGUISetText(child,math.random(1,100))
DGS:dgsSetText(child,math.random(1,100))
end
end
end,1000,0)
end,1000,0)

Revision as of 03:52, 21 January 2018

This function returns one of the child dgs elements of a given parent dgs element. The child dgs element is selected by its index (0 for the first child, 1 for the second and so on).

Syntax

element dgsGetChild ( element dgsParent, int index ) 

Required Arguments

  • dgsParent: the dgs element above the one to be returned in the hierarchy.
  • index: the dgs element's index (1 for the first element, 2 for the second, etc).

Returns

Returns the requested dgs element if it exists, or false if it doesn't.

Example

DGS = exports.dgs

parent = DGS:dgsCreateWindow(200,100,400,400,"DGS Parent Window",false)	--Create a window
child1 = DGS:dgsCreateLabel(10,0,380,20,"",false,parent)	--Create child 1
child2 = DGS:dgsCreateLabel(10,20,380,20,"",false,parent)	--Create child 2
child3 = DGS:dgsCreateLabel(10,40,380,20,"",false,parent)	--Create child 3
child4 = DGS:dgsCreateLabel(10,60,380,20,"",false,parent)	--Create child 4

--Set a random number to a random child.
setTimer(function()
	local child = DGS:dgsGetChild(parent,math.random(1,4))
	if isElement(child) then
		DGS:dgsSetText(child,math.random(1,100))
	end
end,1000,0)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips