GuiSetSize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''guiElement:''' the GUI element whose visibility is to be changed
*'''argumentName:''' description
*'''width:''' The desired width setting for the gui element
 
*'''height:''' The desired height setting for the gui element
<!-- Only include this section below if there are optional arguments -->
*'''relative:''' This is whether sizes and positioning are relative.  If this is ''true'', then all x,y,width,height floats must be between 0 and 1, representing sizes relative to the parent.
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' description
*'''argumentName3:''' description


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the gui element's size was set successfully, ''false'' otherwise.
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example creates a gui window and changes the x and y width of the window every 2 seconds.
This example does...
<syntaxhighlight lang="lua">function changeWindowSize ( )
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
--Called by the timer every 2 seconds. It decides an x and y width randomly between .1 and .5
<syntaxhighlight lang="lua">
guiSetSize ( myWindow, ( math.random( 10, 50 ) / 100 ), ( math.random( 10, 50 ) / 100 ), true )
--This line does...
end
blabhalbalhb --abababa
 
--This line does this...
--Create a gui window called 'myWindow'
mooo
myWindow = guiCreateWindow ( 0.3, 0.3, 0.5, 0.60, "GUI window title", true )
</syntaxhighlight>
--Set a timer to change the window's size every 2 seconds, infinite times
setTimer ( changeWindowSize, 2000, 0 )</syntaxhighlight>


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{GUI_functions}}
{{GUI_functions}}
[[Category:Incomplete]] -- leave this unless you complete the function

Revision as of 05:42, 11 October 2007

This function sets the dimensions (size) of a GUI element

Syntax

bool guiSetSize ( element gui, float width, float height, bool relative )

Required Arguments

  • guiElement: the GUI element whose visibility is to be changed
  • width: The desired width setting for the gui element
  • height: The desired height setting for the gui element
  • relative: This is whether sizes and positioning are relative. If this is true, then all x,y,width,height floats must be between 0 and 1, representing sizes relative to the parent.

Returns

Returns true if the gui element's size was set successfully, false otherwise.

Example

This example creates a gui window and changes the x and y width of the window every 2 seconds.

function changeWindowSize ( )
	--Called by the timer every 2 seconds. It decides an x and y width randomly between .1 and .5
	guiSetSize ( myWindow, ( math.random( 10, 50 ) / 100 ), ( math.random( 10, 50 ) / 100 ), true )
end

--Create a gui window called 'myWindow'
myWindow = guiCreateWindow ( 0.3, 0.3, 0.5, 0.60, "GUI window title", true )
--Set a timer to change the window's size every 2 seconds, infinite times
setTimer ( changeWindowSize, 2000, 0 )

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