DgsGetChildren: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (DGS OOP Syntax changing)
 
(4 intermediate revisions by 3 users not shown)
Line 4: Line 4:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element dgsGetChildren ( element dgsParent )  
table dgsGetChildren ( element dgsParent )  
</syntaxhighlight>
</syntaxhighlight>
{{DGS/OOP|
    Method = DGSElement:getChildren|
    Variable = children
}}


===Required Arguments===  
===Required Arguments===  
Line 17: Line 21:
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 all child dgs elements.
--Set a random number to all child dgs elements.
Line 27: Line 31:
local children = DGS:dgsGetChildren(parent)
local children = DGS:dgsGetChildren(parent)
for id,child in ipairs(children) do
for id,child in ipairs(children) do
DGS:dgsDxGUISetText(child,math.random(1,100))
DGS:dgsSetText(child,math.random(1,100))
end
end
end,1000,0)
end,1000,0)
Line 33: Line 37:


==See Also==
==See Also==
{{DGSFUNCTIONS}}
 
===<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>===
{{DGS General Functions}}
 
===<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>===
{{DGS Events/General}}

Latest revision as of 19:00, 3 May 2021

This function returns all of the child dgs elements of a given parent dgs element.

Syntax

table dgsGetChildren ( element dgsParent ) 

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

Method: DGSElement:getChildren(...)
Variable: .children

Required Arguments

  • dgsParent: the dgs element above the one to be returned in the hierarchy.

Returns

Returns a table includes the child dgs elements of the parent, 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 all child dgs elements.
setTimer(function()
	local children = DGS:dgsGetChildren(parent)
	for id,child in ipairs(children) do
		DGS:dgsSetText(child,math.random(1,100))
	end
end,1000,0)

See Also

General Functions

General Events