GuiComboBoxGetItemText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP syntax)
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string guiComboBoxGetItemText ( element comboBox, int itemId )
string guiComboBoxGetItemText ( element comboBox, int itemId )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Combobox|GuiComboBox]]:getItemText}}


===Required Arguments===  
===Required Arguments===  
Line 31: Line 32:
==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
{{GUI_events}}

Latest revision as of 20:38, 7 November 2018

This function retrieves the text from a specific combobox item.

Syntax

string guiComboBoxGetItemText ( element comboBox, int itemId )

OOP Syntax Help! I don't understand this!

Method: GuiComboBox:getItemText(...)


Required Arguments

  • comboBox: The combobox containing the item you're interested in
  • itemId: The index of the item

Returns

Returns the text of the item if the arguments are right, false otherwise.

Example

This outputs selected item's text to the chatbox.

local x,y = guiGetScreenSize()
local guiWindow = createWindow(x/2-500,y/2-500,500,500,"myWindow",false,nil)
local comboBox = guiCreateComboBox(0.1,0,1,0.8,0.8,"Select a value please",true,guiWindow)
guiComboBoxAddItem(comboBox,"value1")
local item = guiComboBoxGetSelected(comboBox)
local text = guiComboBoxGetItemText(comboBox, item)
if text then
    outputChatBox("You have selected: " .. text) 
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