GuiComboBoxSetOpen: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ {{New feature/item|3.0157|1.5.6|14489|This function set combo box state as open or close.}} ==Syntax== <syntaxhighlight lang="lua"> bool guiCom...")
 
No edit summary
Line 10: Line 10:
===Required Arguments===  
===Required Arguments===  
*'''comboBox:''' The combobox to be opened or closed.
*'''comboBox:''' The combobox to be opened or closed.
*'''state:''' The state of combobox. True, if the combobox is to be opened. False if the combobox is to be closed.  
*'''state:''' The state of combobox. true, if the combobox is to be opened. false if the combobox is to be closed.  


===Returns===
===Returns===

Revision as of 17:06, 23 September 2018

This function set combo box state as open or close.

Syntax

bool guiComboBoxSetOpen( element comboBox, bool state)

Required Arguments

  • comboBox: The combobox to be opened or closed.
  • state: The state of combobox. true, if the combobox is to be opened. false if the combobox is to be closed.

Returns

Returns true if is successful, false otherwise.

Example

This example opens/closes the combobox after clicking the button.

local isOpened = false
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 isOpened then
		guiComboBoxSetOpen(comboBox, true) -- open the combobox
		guiSetText(source, 'Hide numbers')
		isOpened = true
	else
		guiComboBoxSetOpen(comboBox, false) -- close the combobox
		guiSetText(source, 'Show numbers')
		isOpened = false
	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