GuiSetVisible: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
(7 intermediate revisions by 5 users not shown) | |||
Line 7: | Line 7: | ||
bool guiSetVisible ( element guiElement, bool state ) | bool guiSetVisible ( element guiElement, bool state ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[GUI widgets|GuiElement]]:setVisible|visible|guiGetVisible}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 16: | Line 17: | ||
==Example== | ==Example== | ||
This example creates a | This example creates a GUI window and changes its visibility every 2 seconds, indefinitely. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- 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, indefinitely | |||
setTimer( function( ) | |||
--Set a timer to change the window's visibility every 2 seconds, | -- We toggle the visibility here by taking the opposite result of guiGetVisible (false => true, true => false), hence toggling its visibility | ||
setTimer ( | guiSetVisible( myWindow, not guiGetVisible( myWindow ) ) | ||
end, 2000, 0 ) | |||
</syntaxhighlight> | |||
This example creates a | This example creates a GUI window with ''yes'' and ''no'' buttons and you can toggle its visibility with the ''x'' key. | ||
< | |||
<syntaxhighlight lang="lua">addEventHandler( "onClientResourceStart", resourceRoot, | |||
newgui | function( ) | ||
newgui.wind[ 1 ] = guiCreateWindow( 434, 304, 280, 123, "New Window", false ) | |||
guiWindowSetSizable( newgui.wind[ 1 ], false ) | |||
newgui.button[ 1 ] = guiCreateButton( 35, 46, 87, 40, "yes", false, newgui.wind[ 1 ] ) | |||
newgui.button[ 2 ] = guiCreateButton( 166, 49, 92, 37, "no", false, newgui.wind[ 1 ] ) | |||
showCursor( true ) | |||
end | |||
) | |||
bindKey ( " | bindKey( "x", "down", | ||
function( ) | |||
local state = not guiGetVisible( newgui.wind[ 1 ] ) | |||
guiSetVisible( newgui.wind[ 1 ], state ) | |||
showCursor( state ) | |||
)</syntaxhighlight | end | ||
)</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{GUI_functions}} | {{GUI_functions}} | ||
{{GUI_events}} | |||
[[en:GuiSetVisible]] | |||
[[fr:GuiSetVisible]] |
Latest revision as of 21:06, 21 February 2021
This function changes the visibility state of a GUI element.
Syntax
bool guiSetVisible ( element guiElement, bool state )
OOP Syntax Help! I don't understand this!
- Method: GuiElement:setVisible(...)
- Variable: .visible
- Counterpart: guiGetVisible
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, indefinitely.
-- 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, indefinitely setTimer( function( ) -- We toggle the visibility here by taking the opposite result of guiGetVisible (false => true, true => false), hence toggling its visibility guiSetVisible( myWindow, not guiGetVisible( myWindow ) ) end, 2000, 0 )
This example creates a GUI window with yes and no buttons and you can toggle its visibility with the x key.
addEventHandler( "onClientResourceStart", resourceRoot, function( ) newgui.wind[ 1 ] = guiCreateWindow( 434, 304, 280, 123, "New Window", false ) guiWindowSetSizable( newgui.wind[ 1 ], false ) newgui.button[ 1 ] = guiCreateButton( 35, 46, 87, 40, "yes", false, newgui.wind[ 1 ] ) newgui.button[ 2 ] = guiCreateButton( 166, 49, 92, 37, "no", false, newgui.wind[ 1 ] ) showCursor( true ) end ) bindKey( "x", "down", function( ) local state = not guiGetVisible( newgui.wind[ 1 ] ) guiSetVisible( newgui.wind[ 1 ], state ) showCursor( state ) end )
See Also
General functions
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign
Windows
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel