GuiCheckBoxGetSelected

From Multi Theft Auto: Wiki
Revision as of 20:34, 7 November 2018 by StrixG (talk | contribs) (OOP syntax)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function gets a checkbox's selection state.

Syntax

bool guiCheckBoxGetSelected ( element theCheckbox )

OOP Syntax Help! I don't understand this!

Method: GuiCheckBox:getSelected(...)
Variable: .selected
Counterpart: guiCheckBoxSetSelected


Required Arguments

  • theCheckbox : The checkbox you wish to retrieve the selection state of.

Returns

Returns true if the checkbox is selected, false if it is not.

Example

This example makes a different beep based on the state when any checkbox has been clicked.

function checkboxBleepWhenClicked()
    if ( getElementType(source) == "gui-checkbox" ) then -- Is the element clicked a checkbox?
        if ( guiCheckBoxGetSelected(source) ) then
            playSoundFrontEnd(1) -- If the checkbox is selected play sound 1.
        else
            playSoundFrontEnd(2) -- If the checkbox isn't selected play sound 2.
        end
    end
end
addEventHandler("onClientGUIClick", root, checkboxBleepWhenClicked, false)

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