GuiGetVisible: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
This function returns the visibility state of a GUI element.
__NOTOC__
This function determines if a GUI element is visible.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiGetVisible ( element gui )
bool guiGetVisible ( element guiElement )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[GUI widgets|GuiElement]]:getVisible|visible|guiSetVisible}}


===Required Arguments===  
===Required Arguments===  
*'''gui:''' the GUI element to be checked
*'''guiElement:''' the GUI element to be checked


===Returns===
===Returns===
Line 14: Line 16:


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example toggles the visibility of myWindow.
This example does...
<syntaxhighlight lang="lua">function guiToggleVisible ( )       
<!-- 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 -->
        if ( guiGetVisible ( myWindow ) == true ) then -- check if the gui element is visible             
<syntaxhighlight lang="lua">
                guiSetVisible ( myWindow, false ) -- if it is, we hide it
--This line does...
        else             
blabhalbalhb --abababa
                guiSetVisible ( myWindow, true ) -- if not, we make it visible
--This line does this...
        end
mooo
end
</syntaxhighlight>
 
myWindow = guiCreateWindow ( 0, 0, .5, .5, "my window", true ) -- Create the gui window
bindKey ( "space", "down", guiToggleVisible ) --bind the player's spacebar to the function guiToggleVisible</syntaxhighlight>


==See Also==
==See Also==
{{GUI_functions}}
{{GUI_functions}}
[[Category:Incomplete]]
{{GUI_events}}

Latest revision as of 17:19, 21 November 2018

This function determines if a GUI element is visible.

Syntax

bool guiGetVisible ( element guiElement )

OOP Syntax Help! I don't understand this!

Method: GuiElement:getVisible(...)
Variable: .visible
Counterpart: guiSetVisible


Required Arguments

  • guiElement: the GUI element to be checked

Returns

Returns true if the element is visible, false otherwise.

Example

This example toggles the visibility of myWindow.

function guiToggleVisible ( )        
        if ( guiGetVisible ( myWindow ) == true ) then -- check if the gui element is visible               
                guiSetVisible ( myWindow, false ) -- if it is, we hide it
        else              
                guiSetVisible ( myWindow, true ) -- if not, we make it visible
        end
end

myWindow = guiCreateWindow ( 0, 0, .5, .5, "my window", true ) -- Create the gui window
bindKey ( "space", "down", guiToggleVisible ) --bind the player's spacebar to the function guiToggleVisible

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