DgsComboBoxGetItemColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This function get the color of a comboBox item. ==Syntax== <syntaxhighlight lang="lua"> bool dgsDxComboBoxGetItemColor ( element comboBox, int...")
 
Line 16: Line 16:


==Example==  
==Example==  
<section name="Client" class="client" show="true">
This example creates a player list on the right of the screen and fills it with players online and sets the combo box item color according to their nametag color.
This example creates a player list on the right of the screen and fills it with players online and sets the combo box item color according to their nametag color.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 45: Line 44:
end)
end)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{DGSFUNCTIONS}}
{{DGSFUNCTIONS}}

Revision as of 08:42, 11 August 2017

This function get the color of a comboBox item.

Syntax

bool dgsDxComboBoxGetItemColor ( element comboBox, int item )

Required Arguments

  • comboBox: The combo box element
  • item: Item ID

Returns

Returns number if the item color was got successfully, false otherwise.

Example

This example creates a player list on the right of the screen and fills it with players online and sets the combo box item color according to their nametag color.

DGS = exports.dgs

function createPlayerComboBox ( )
	--Create the grid list element
	playerComboBox = DGS:dgsDxCreateComboBox ( 0.80, 0.10, 0.15, 0.60, true )
	for id, player in ipairs ( getElementsByType ( "player" ) ) do
		local item = DGS:dgsDxComboBoxAddItem( playerComboBox )
		local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color.
		DGS:dgsDxComboBoxSetItemText ( playerComboBox , item, getPlayerName ( player ) )
		DGS:dgsDxComboBoxSetItemColor ( playerComboBox , item, tocolor( r, g, b, 255 ) ) -- We set the grid list item color to the returned values of getPlayerNametagColor.
	end
end
addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList )

addEventHandler ( "onClientDgsDxComboBoxSelect", root, function()
	if source == playerComboBox then
		local item = DGS:dgsDxComboBoxGetSelectedItem(source)
		if item ~= -1 then
			local color = DGS:dgsDxComboBoxGetItemColor( source, item )
			if color then
				outputChatBox( "Item : "..item.." ; Color : "..color)
			end
		end
	end
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