DgsComboBoxSetItemColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsDxComboBoxSetItemColor ( element comboBox, int item, int color)
bool dgsComboBoxSetItemColor ( element comboBox, int item, int color)
</syntaxhighlight>  
</syntaxhighlight>  


Line 11: Line 11:
*'''comboBox:''' The combo box element
*'''comboBox:''' The combo box element
*'''item:''' Item ID
*'''item:''' Item ID
*'''color:''' The amount of the color (0-‭4294967295‬)
*'''color:''' An integer of color (0-‭4294967295‬), use [[tocolor]] for converting RGBA to color number.


===Returns===
===Returns===
Line 23: Line 23:
function createPlayerComboBox ( )
function createPlayerComboBox ( )
--Create the grid list element
--Create the grid list element
local playerComboBox = DGS:dgsDxCreateComboBox ( 0.80, 0.10, 0.15, 0.60, true )
local playerComboBox = DGS:dgsCreateComboBox ( 0.80, 0.10, 0.15, 0.60,"Select a player", true )
for id, player in ipairs ( getElementsByType ( "player" ) ) do
for id, player in ipairs ( getElementsByType ( "player" ) ) do
local item = DGS:dgsDxComboBoxAddItem( playerComboBox )
local item = DGS:dgsComboBoxAddItem( playerComboBox )
local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color.
local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color.
DGS:dgsDxComboBoxSetItemText ( playerComboBox , item, getPlayerName ( player ) )
DGS:dgsComboBoxSetItemText ( 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.
DGS:dgsComboBoxSetItemColor ( playerComboBox , item, tocolor( r, g, b, 255 ) ) -- We set the grid list item color to the returned values of getPlayerNametagColor.
end
end
end
end

Latest revision as of 12:48, 7 February 2022

This function changes the color of a comboBox item.

Syntax

bool dgsComboBoxSetItemColor ( element comboBox, int item, int color)

Required Arguments

  • comboBox: The combo box element
  • item: Item ID
  • color: An integer of color (0-‭4294967295‬), use tocolor for converting RGBA to color number.

Returns

Returns true if the item color was set 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
	local playerComboBox = DGS:dgsCreateComboBox ( 0.80, 0.10, 0.15, 0.60,"Select a player", true )
	for id, player in ipairs ( getElementsByType ( "player" ) ) do
		local item = DGS:dgsComboBoxAddItem( playerComboBox )
		local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color.
		DGS:dgsComboBoxSetItemText ( playerComboBox , item, getPlayerName ( player ) )
		DGS:dgsComboBoxSetItemColor ( 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 )

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