GuiCheckBoxSetSelected: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(OOP syntax)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Client function}}
__NOTOC__  
__NOTOC__  
This function selects (ticks) or unselects a checkbox.
This function selects (ticks) or unselects a checkbox.
Line 5: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiCheckBoxSetSelected ( element theCheckbox, bool state )
bool guiCheckBoxSetSelected ( element theCheckbox, bool state )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Checkbox|GuiCheckBox]]:setSelected|selected|guiCheckBoxGetSelected}}


===Required Arguments===  
===Required Arguments===  
Line 15: Line 17:


==Example==
==Example==
This page lacks an example
This example creates 2 checkboxes and sets one of them selected then checks if the first one is selected and if it is then the second one would be set selected.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">checkedBox = guiCreateCheckBox(20,30,150,20,"Checked checkbox",true,false)
--add an example here
uncheckedBox = guiCreateCheckBox(20,30,150,20,"UnChecked checkbox",false,false)
 
if(guiCheckBoxGetSelected(checkedBox))then
guiCheckBoxSetSelected(uncheckedBox,true)
else
guiCheckBoxSetSelected(checkedBox,true)
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{GUI_functions}}
{{GUI_functions}}
[[Category:Needs_Example]]
{{GUI_events}}

Latest revision as of 20:34, 7 November 2018

This function selects (ticks) or unselects a checkbox.

Syntax

bool guiCheckBoxSetSelected ( element theCheckbox, bool state )

OOP Syntax Help! I don't understand this!

Method: GuiCheckBox:setSelected(...)
Variable: .selected
Counterpart: guiCheckBoxGetSelected


Required Arguments

  • theCheckbox: The GUI element in which you wish to change the selection state of
  • state: The state of the checkbox, where true indicates selected, and false indicates unselected.

Returns

Returns true if the checkbox's selection state was successfully set, false otherwise.

Example

This example creates 2 checkboxes and sets one of them selected then checks if the first one is selected and if it is then the second one would be set selected.

checkedBox = guiCreateCheckBox(20,30,150,20,"Checked checkbox",true,false)
uncheckedBox = guiCreateCheckBox(20,30,150,20,"UnChecked checkbox",false,false)

if(guiCheckBoxGetSelected(checkedBox))then
	guiCheckBoxSetSelected(uncheckedBox,true)
else
	guiCheckBoxSetSelected(checkedBox,true)
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