GuiComboBoxIsOpen: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Modify example)
(OOP syntax)
 
Line 6: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiComboBoxIsOpen( element comboBox )
bool guiComboBoxIsOpen( element comboBox )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Combobox|GuiComboBox]]:isOpen|open|guiComboBoxSetOpen}}


===Required Arguments===  
===Required Arguments===  

Latest revision as of 20:48, 7 November 2018

This function returns the state of combobox.

Syntax

bool guiComboBoxIsOpen( element comboBox )

OOP Syntax Help! I don't understand this!

Method: GuiComboBox:isOpen(...)
Variable: .open
Counterpart: guiComboBoxSetOpen


Required Arguments

  • comboBox: The combo box to get the state.

Returns

Returns true if combobox is opened, false if combobox is closed, nil otherwise.

Example

This example opens/closes the combobox after clicking the button. Checking if combobox is opened and change button text.

local comboBox = guiCreateComboBox(0.30,0.45,0.30,0.20,'Test',true) -- create the gui combo-box
local openButton = guiCreateButton(0.35,0.31,0.15,0.15,'Show numbers',true) -- create the button

for i = 1,20 do
	guiComboBoxAddItem(comboBox, tostring(i)) -- add items
end

addEventHandler('onClientGUIClick',openButton,function()
	if not guiComboBoxIsOpen(comboBox) then
		guiComboBoxSetOpen(comboBox, true) -- open the combobox
		guiSetText(source, 'Hide numbers')
	else
		guiComboBoxSetOpen(comboBox, false) -- close the combobox
		guiSetText(source, 'Show numbers')
	end
end)

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