DgsGetElementsFromResource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 17: Line 17:


==Example==  
==Example==  
This example gets the text of a pre-made dgs element and outputs it to chat box.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
-- We create a dummy dgs label to get text of
for i=1,10 do
local dummyGUIElement = DGS:dgsDxCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )
DGS:dgsDxCreateLabel ( math.random(0,1),math.random(0,1),0.2,0.1, "Hello world"..i, true ) --Create Labels without storing into variables.
-- Output the text of the label to chat box
end
outputChatBox ( "Text in the DGS label: " .. DGS:dgsDxGUIGetText ( dummyGUIElement ) )
 
for k,v in ipairs(DGS:dgsGetDxGUIFromResource()) do --Get All DGS Dx GUIs that created by this resource.
if DGS:dgsGetType(v) == "dgs-dxlabel" then
local text = DGS:dgsDxGUIGetText(v) --Get Label Text.
outputChatBox(text) --Out put Label Text.
end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{DGSFUNCTIONS}}
{{DGSFUNCTIONS}}

Revision as of 03:53, 31 August 2017

This function is used to get DGS elements which were created by other resources.

Syntax

table dgsGetDxGUIFromResource( [ resource res ] )

Required Arguments

None

Optional Arguments

  • res: The resource which DGS elements were created by.

Returns

Returns a table containing DGS elements which were created by the resource, false otherwise.

Example

DGS = exports.dgs
for i=1,10 do
	DGS:dgsDxCreateLabel ( math.random(0,1),math.random(0,1),0.2,0.1, "Hello world"..i, true ) --Create Labels without storing into variables.
end

for k,v in ipairs(DGS:dgsGetDxGUIFromResource()) do --Get All DGS Dx GUIs that created by this resource.
	if DGS:dgsGetType(v) == "dgs-dxlabel" then
		local text = DGS:dgsDxGUIGetText(v)  --Get Label Text.
		outputChatBox(text) --Out put Label Text.
	end
end

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