GuiScrollBarSetScrollPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{client function}}
{{client function}}
{{Needs Example}}
This function is used to set the scroll amount of a scrollbar as a percentage.
This function is used to set the scroll amount of a scrollbar as a percentage.


Line 16: Line 15:


==Example==
==Example==
 
In this example, you can set the scrolling position using the command /pos <amount>
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local window = guiCreateWindow(0.3,0.3,0.3,0.3,"Scroll-Position",true)
local window = guiCreateWindow(0.3,0.3,0.3,0.3,"Scroll-Position",true)
Line 22: Line 21:


function scroll_bar_setPos(_,position)
function scroll_bar_setPos(_,position)
local position = tonumber(position)
if (tonumber(position)) then -- If we have typed a position
if (position) then -- If we have typed a position
guiScrollBarSetScrollPosition(scroll_bar,position) --Set the position in the scroll bar
guiScrollBarSetScrollPosition(scroll_bar,position) --Set the position in the scroll bar
end
end
Line 32: Line 30:
==See Also==
==See Also==
{{GUI_functions}}
{{GUI_functions}}
[[Catogory:Needs_Example]]
{{GUI_events}}

Latest revision as of 12:41, 20 September 2021

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

Syntax

bool guiScrollBarSetScrollPosition ( gui-scrollBar theScrollBar, float amount )

Required Arguments

  • theScrollBar: The 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.

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>

local window = guiCreateWindow(0.3,0.3,0.3,0.3,"Scroll-Position",true)
local scroll_bar = guiCreateScrollBar(5,25,30,245,false,false,window)

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

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI