DgsCreateScrollPane

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This creates a DGS scroll pane.

DGS Scroll Pane

Syntax

element dgsDxCreateScrollPane( float x, float y, float width, float height, bool relative, [dgs-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:dgsDxCreateWindow(5,5,130,150,"",false)
		-- 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)
	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:dgsDxCreateLabel(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