GuiGetSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(12 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
This function gets the size of a GUI element
__NOTOC__
 
This function gets the size of a GUI element.
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float, float guiGetSize ( element theElement )
float float guiGetSize ( element theElement, bool relative )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[GUI widgets|GuiElement]]:getSize||guiSetSize}}


===Required Arguments===  
===Required Arguments===  
*'''theElement:''' The GUI element to get size of
*'''theElement:''' The GUI element to get size of.
*'''relative:''' A boolean representing whether the size should be relative to the element's parent width, or an absolute size in pixels.


===Returns===
===Returns===
Returns the GUI element size if the function has been successfull, ''false'' otherwise.
Returns the GUI element size ''x'' and ''y'' if the function has been successful, ''false'' otherwise.


==Example==  
==Example==  
This example creates a random sized gui window and outputs it's size to chatbox...
This example creates a random sized gui window and outputs its size to the chatbox.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function test ()
local window = guiCreateWindow ( 0, 0, (math.random ( 0, 100 ) / 100), (math.random ( 0, 100 ) / 100), "test", true )  
        --Create the window
-- Create the window
        local window = guiCreateWindow ( 0, 0, randInt ( 0, 100 ) / 100, randInt ( 0, 100 ) / 100, "test", true )
local x, y = guiGetSize ( window, false ) -- Get the gui window size
        --Get it's size and output to chatbox
outputChatBox ( "Window size: " .. x .. " " .. y ) --output the gui window size
        local x, y = guiGetSize ( window )
        outputChatBox ( "Window size: "..x.." "..y )
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_functions}}
{{GUI functions}}
[[Category:Need_Syntax]]  -- leave this until syntax is available. Cannot document the function or event without syntax.
{{GUI_events}}

Latest revision as of 17:18, 21 November 2018

This function gets the size of a GUI element.

Syntax

float float guiGetSize ( element theElement, bool relative )

OOP Syntax Help! I don't understand this!

Method: GuiElement:getSize(...)
Counterpart: guiSetSize


Required Arguments

  • theElement: The GUI element to get size of.
  • relative: A boolean representing whether the size should be relative to the element's parent width, or an absolute size in pixels.

Returns

Returns the GUI element size x and y if the function has been successful, false otherwise.

Example

This example creates a random sized gui window and outputs its size to the chatbox.

local window = guiCreateWindow ( 0, 0, (math.random ( 0, 100 ) / 100), (math.random ( 0, 100 ) / 100), "test", true ) 
-- Create the window
local x, y = guiGetSize ( window, false ) -- Get the gui window size
outputChatBox ( "Window size: " .. x .. " " .. y ) --output the gui window size

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