OnClientGUIComboBoxAccepted: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
{{Client event}}
{{Client event}}
__NOTOC__  
__NOTOC__  
This event is called when a ComboBox get accepted
This event is called when a [[Element/GUI/Combobox|combobox]] gets accepted.


==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element ComboBox
element comboBox
</syntaxhighlight>
</syntaxhighlight>
*'''ComboBox:''' the ComboBox that got accepted.
*'''comboBox:''' the [[Element/GUI/Combobox|combobox]] that got accepted.


==Example==
==Example==
This example will set the memo text to the selected combo box item text
This example will set the memo text to the selected combobox item text.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Combo = guiCreateComboBox ( 0.20, 0.03, 0.25, 0.30, "Example", true )
Combo = guiCreateComboBox ( 0.20, 0.03, 0.25, 0.30, "Example", true )

Revision as of 22:32, 2 April 2018

This event is called when a combobox gets accepted.

Parameters

element comboBox
  • comboBox: the combobox that got accepted.

Example

This example will set the memo text to the selected combobox item text.

Combo = guiCreateComboBox ( 0.20, 0.03, 0.25, 0.30, "Example", true )
Memo = guiCreateMemo( 10, 50, 500, 150, "", false)
addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot,
    function ( comboBox )
        if ( comboBox == Combo ) then
            local item = guiComboBoxGetSelected ( Combo )
            local text = tostring ( guiComboBoxGetItemText ( Combo , item ) )
            if ( text ~= "" ) then
                 guiSetText ( Memo , text )
            end
        end
    end
)

See Also

GUI events

Input

GUI


Client event functions