GuiSetVisible: Difference between revisions

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


==Example==  
==Example==  
This example toggles gui element visibility.
This example creates a gui window and changes its visibility every 2 seconds, infinite times.
<syntaxhighlight lang="lua">
 
function guiToggleVisible ( guiElement )
<syntaxhighlight lang="lua">function changeVisibility ( )
-- we check if the gui element is visible
        -- we check if the gui element is visible
if guiGetVisible ( guiElement ) then
        if guiGetVisible ( myWindow ) then
-- if it is, we hide it
                -- if it is, we hide it
guiSetVisible ( guiElement, false )
                guiSetVisible ( myWindow, false )
else
        else
-- if not, we make it visible
                -- if not, we make it visible
guiSetVisible ( guiElement, true )
                guiSetVisible ( myWindow, true )
end
        end
end
end
</syntaxhighlight>
 
--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 visibility every 2 seconds, infinite times
setTimer ( changeVisibility, 2000, 0 )</syntaxhighlight>


==See Also==
==See Also==
{{GUI_functions}}
{{GUI_functions}}

Revision as of 05:47, 11 October 2007

This function changes the visibility state of a GUI element.

Syntax

bool guiSetVisible ( element guiElement, bool state )

Required Arguments

  • guiElement: the GUI element whose visibility is to be changed
  • state: the new visibility state

Returns

Returns true if the element's visibility could be changed, false otherwise.

Example

This example creates a gui window and changes its visibility every 2 seconds, infinite times.

function changeVisibility ( )
        -- we check if the gui element is visible
        if guiGetVisible ( myWindow ) then
                -- if it is, we hide it
                guiSetVisible ( myWindow, false )
        else
                -- if not, we make it visible
                guiSetVisible ( myWindow, true )
        end
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 visibility every 2 seconds, infinite times
setTimer ( changeVisibility, 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