Difference between revisions of "DgsGetChild"

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (DGS (OOP Syntax)/(Template Organization) Mission)
m (DGS OOP Syntax changing)
Line 6: Line 6:
element dgsGetChild ( element dgsParent, int index )  
element dgsGetChild ( element dgsParent, int index )  
    Method = DGSElement:getChild
===Required Arguments===  
===Required Arguments===  

Latest revision as of 18:59, 3 May 2021

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).


element dgsGetChild ( element dgsParent, int index ) 

DGS OOP Syntax Help! I don't understand this!

Method: DGSElement:getChild(...)

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 the requested dgs element if it exists, or false if it doesn't.


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.
	local child = DGS:dgsGetChild(parent,math.random(1,4))
	if isElement(child) then

See Also

General Functions

General Events