GuiComboBoxClear: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP syntax)
 
(3 intermediate revisions by 3 users not shown)
Line 6: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiComboBoxClear ( element comboBox )
bool guiComboBoxClear ( element comboBox )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Combobox|GuiComboBox]]:clear}}


===Required Arguments===  
===Required Arguments===  
Line 15: Line 16:


==Example==
==Example==
<section name="Client" class="client" show="true">
This example creates a combo box with all server vehicles on it, with a command to clear the combo box.
This example creates a combo box with all server vehicles on it, with a command to clear the combo box.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 29: Line 29:
addCommandHandler ( "clear",
addCommandHandler ( "clear",
function ( )
function ( )
guiComboBoxClear ( vehiclesComboBox )
guiComboBoxClear ( vehiclesComboBox ) -- We clear our combo box removing all vehicles.
end
end
)
)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
[[Category:Needs_Example]]
{{GUI_events}}

Latest revision as of 20:38, 7 November 2018

This function removes all the items from a combobox.

Syntax

bool guiComboBoxClear ( element comboBox )

OOP Syntax Help! I don't understand this!

Method: GuiComboBox:clear(...)


Required Arguments

  • comboBox: The combobox element to be cleared

Returns

Returns true if the combobox element is valid and has been cleared successfully, false otherwise.

Example

This example creates a combo box with all server vehicles on it, with a command to clear the combo box.

addEventHandler ( "onClientResourceStart", resourceRoot,
	function ( )
		vehiclesComboBox = guiCreateComboBox ( 400, 100, 200, 5 * #getElementsByType ( "vehicle" ), "", false ) -- We create a combo box.
		for index, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- We loop through all vehicles.
			guiComboBoxAddItem ( vehiclesComboBox, getVehicleName ( vehicle ) ) -- We add the vehicle name to our combo box.
		end
	end
)

addCommandHandler ( "clear",
	function ( )
		guiComboBoxClear ( vehiclesComboBox ) -- We clear our combo box removing all vehicles.
	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