DgsCreateScrollPane: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This creates a DGS scroll pane. frame|Example GUI ScrollPane. ==Syntax== <syntaxhighlight lang="lua"> element dgsD...")
 
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:
__NOTOC__
__NOTOC__
This creates a DGS scroll pane.
This creates a DGS scroll pane.
[[Image:gui-scrollpane.png|frame|Example GUI ScrollPane.]]
[[Image:DGS_Scroll_Pane.png|thumb|DGS Scroll Pane]]
 
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element dgsDxCreateScrollPane( float x, float y, float width, float height, bool relative, [dgs-element parent = nil])
element dgsCreateScrollPane( float x, float y, float width, float height, bool relative [, element parent = nil ] )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''x:''' the 2D x offset of the DGS scrollpane from its parent. This is affected by the relative argument.
*'''x:''' the 2D x offset of the DGS scrollpane from its parent. This is affected by the relative argument.
*'''y:''' the 2D y offset of the DGS scrollbar from its parent. This is affected by the relative argument.
*'''y:''' the 2D y offset of the DGS scrollpane from its parent. This is affected by the relative argument.
*'''width:''' the width of the DGS scrollpane. This is affected by the relative argument.
*'''width:''' the width of the DGS scrollpane. This is affected by the relative argument.
*'''height:''' the height of the DGS scrollpane. This is affected by the relative argument.
*'''height:''' the height of the DGS scrollpane. This is affected by the relative argument.
Line 29: Line 28:
function()
function()
-- create a window and create a scrollpane on it
-- create a window and create a scrollpane on it
local window = DGS:dgsDxCreateWindow(5,5,130,150,"",false)
local window = DGS:dgsCreateWindow(5,5,130,150,"",false)
-- the width and height values here are largely irrelevant as the scrollpane will automatically resize when needed
-- the width and height values here are largely irrelevant as the scrollpane will automatically resize when needed
scrollpane = DGS:dgsDxCreateScrollPane(0,0,130,150,false,window)
scrollpane = DGS:dgsCreateScrollPane(0,0,130,150,false,window)
end
end
)
)
Line 47: Line 46:
for i,v in ipairs(getElementsByType("player")) do
for i,v in ipairs(getElementsByType("player")) do
-- create a label with their name on the scrollpane
-- create a label with their name on the scrollpane
DGS:dgsDxCreateLabel(5,i*20,90,20,tostring(getPlayerName(v)),false,scrollpane)
DGS:dgsCreateLabel(5,i*20,90,20,tostring(getPlayerName(v)),false,scrollpane)
end
end
end
end

Latest revision as of 09:26, 17 January 2021

This creates a DGS scroll pane.

DGS Scroll Pane

Syntax

element dgsCreateScrollPane( float x, float y, float width, float height, bool relative [, element parent = nil ] )

Required Arguments

  • x: the 2D x offset of the DGS scrollpane from its parent. This is affected by the relative argument.
  • y: the 2D y offset of the DGS scrollpane from its parent. This is affected by the relative argument.
  • width: the width of the DGS scrollpane. This is affected by the relative argument.
  • height: the height of the DGS scrollpane. This is affected by the relative argument.
  • relative: whether sizes and positions are relative to their parent's. If this is true, then all measures must be between 0 and 1, representing sizes/positions as a fraction of the parent widget's size.

Optional Arguments

  • parent: the dgs-element this scrollpane is attached to. By default, it is nil, meaning the widget is attached to the background.

Returns

The dgs-element if created, otherwise false.

Example

This example creates a small window with a scrollpane on. Using the /fill command you can populate the scrollpane with the names of every player in the server.

DGS = exports.dgs
addEventHandler("onClientResourceStart",resourceRoot,
	function()
		-- create a window and create a scrollpane on it
		local window = DGS:dgsCreateWindow(5,5,130,150,"",false)
		-- the width and height values here are largely irrelevant as the scrollpane will automatically resize when needed
		scrollpane = DGS:dgsCreateScrollPane(0,0,130,150,false,window)
	end
)

addCommandHandler("fill",
	function()
		-- if the scrollpane exists
		if scrollpane then
			-- delete all the existing labels
			for i,v in ipairs(DGS:dgsGetChildren(scrollpane)) do
				destroyElement(v)
			end
		
			-- for every player in the server
			for i,v in ipairs(getElementsByType("player")) do
				-- create a label with their name on the scrollpane
				DGS:dgsCreateLabel(5,i*20,90,20,tostring(getPlayerName(v)),false,scrollpane)
			end
		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