DgsScrollBarSetScrollPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsScrollBarSetScrollBarPosition ( element theScrollBar, float amount )
bool dgsScrollBarSetScrollPosition ( element theScrollBar, float amount [, bool isGrade = false ] )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
*'''theScrollBar''': The dgs scrollbar you want to change the progress of
*'''theScrollBar''': The dgs scrollbar you want to change the progress of
*'''amount''': a float ranging from 0 - 100 representing the amount you wish to set the scroll bar.
*'''amount''': A float ranging from 0 - 100 representing the amount you wish to set the scroll bar.
 
===Optional Arguments===
*'''isGrade''': A bool indicates whether the input value is grade or normal position. ( This only works when there are grades set in scroll bar )


===Returns===
===Returns===
Line 23: Line 26:
function scroll_bar_setPos(_,position)
function scroll_bar_setPos(_,position)
if (tonumber(position)) then -- If we have typed a position
if (tonumber(position)) then -- If we have typed a position
DGS:dgsScrollBarSetScrollBarPosition(scroll_bar,position) --Set the position in the scroll bar
DGS:dgsScrollBarSetScrollPosition(scroll_bar,position) --Set the position in the scroll bar
end
end
end
end

Latest revision as of 02:07, 2 September 2019

This function is used to set the scroll amount of a dgs scrollbar as a percentage.

Syntax

bool dgsScrollBarSetScrollPosition ( element theScrollBar, float amount [, bool isGrade = false ] )

Required Arguments

  • theScrollBar: The dgs scrollbar you want to change the progress of
  • amount: A float ranging from 0 - 100 representing the amount you wish to set the scroll bar.

Optional Arguments

  • isGrade: A bool indicates whether the input value is grade or normal position. ( This only works when there are grades set in scroll bar )

Returns

Returns true if the scroll position was successfully set, false otherwise.

Example

In this example, you can set the scrolling position using the command /pos <amount>

DGS = exports.dgs
local window = DGS:dgsCreateWindow(0.3,0.3,0.3,0.3,"Scroll-Position",true)
local scroll_bar = DGS:dgsCreateScrollBar(5,25,30,245,false,false,window)

function scroll_bar_setPos(_,position)
	if (tonumber(position)) then -- If we have typed a position
		DGS:dgsScrollBarSetScrollPosition(scroll_bar,position) --Set the position in the scroll bar
	end
end
addCommandHandler("pos",scroll_bar_setPos)

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