DgsComboBoxGetSelectedItem: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
Line 19: Line 19:
DGS = exports.dgs
DGS = exports.dgs


comboBox = DGS:dgsCreateComboBox(200,200,100,30,false)
comboBox = DGS:dgsCreateComboBox(200,200,100,30,"test",false)
for i=1,5 do
for i=1,5 do
DGS:dgsComboBoxAddItem(comboBox,i.."test")
DGS:dgsComboBoxAddItem(comboBox,i.."test")

Latest revision as of 05:32, 19 June 2018

This function returns the index of the selected dgs combobox item.

Syntax

int dgsComboBoxGetSelectedItem ( element comboBox )

Required Arguments

  • comboBox: the dgs combobox you want to know the selected item index of

Returns

Returns the index of the selected item if the specified dgs combobox is valid and has a selected item, -1 if no item is selected, false or nil otherwise.

Example

This example outputs selected item's text and ID to the chat.

DGS = exports.dgs

comboBox = DGS:dgsCreateComboBox(200,200,100,30,"test",false)
for i=1,5 do
	DGS:dgsComboBoxAddItem(comboBox,i.."test")
end

addCommandHandler("getSelected",function (command)
	local item = DGS:dgsComboBoxGetSelectedItem (comboBox)
	local text = DGS:dgsComboBoxGetItemText(comboBox, item)
	outputChatBox("Currently selected item with ID: " .. tostring(item) .. " and with text: " .. text)
end)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips