Jump to content
Sign in to follow this  
Johnson11B2P

Change Color of a list box entry.

Recommended Posts

So I've created my G.U.I and I want to know if there is any way to change the color of the text in the list box I selected?

Should I handle this in the sqf file that handles the selection of the list box. I found lbSetColor. So my code is 1547 lbSetColor [0,[0,1,0,0.5]]; which does nothing.

/*
* File: RangeSelectGUI.hpp
* Author: [PN]Rex or RJ4706
* Date: 2014 April 25
* Purpose: This file is the GUI for the Range selection screen.
*/

class PN_Range_Select
{
idd=0;
movingenable=true;	
onLoad = "_startUp = [] spawn loadRangeGUI;";
objects[] = {};
class controls
{
	////////////////////////////////////////////////////////
	// GUI EDITOR OUTPUT START (by Rex, v1.063, #Luxale)
	////////////////////////////////////////////////////////

	class PN_Frame: RscFrame
	{
		idc = 1800;
		text = "Range Select"; //--- ToDo: Localize;
		x = 0.298906 * safezoneW + safezoneX;
		y = 0.236 * safezoneH + safezoneY;
		w = 0.402187 * safezoneW;
		h = 0.528 * safezoneH;
		colorBackground[] = { 1, 1, 1, 1 };
	};
	class PN_ListBox_Ranges: RscListbox
	{
		idc = 1547;
		text = "Select Range"; //--- ToDo: Localize;
		x = 0.329844 * safezoneW + safezoneX;
		y = 0.324 * safezoneH + safezoneY;
		w = 0.345469 * safezoneW;
		h = 0.308 * safezoneH;			
	};
	class PN_Picture_Logo: RscPicture
	{
		idc = 1200;
		text = "Images\logo.paa";
		x = 0.329844 * safezoneW + safezoneX;
		y = 0.258 * safezoneH + safezoneY;
		w = 0.04125 * safezoneW;
		h = 0.055 * safezoneH;
		tooltip = "Project Nova"; //--- ToDo: Localize;
	};
	class RscStructuredText_1100: RscStructuredText
	{
		idc = 1100;
		x = 0.386562 * safezoneW + safezoneX;
		y = 0.258 * safezoneH + safezoneY;
		w = 0.278437 * safezoneW;
		h = 0.055 * safezoneH;
		text = "Project Nova Range Selector";
	};
	class PN_Button_OK: RscButton
	{
		idc = 1600;
		text = "Select"; //--- ToDo: Localize;
		x = 0.396875 * safezoneW + safezoneX;
		y = 0.665 * safezoneH + safezoneY;
		w = 0.04125 * safezoneW;
		h = 0.055 * safezoneH;
		action = "null = execVM ""Range Scripts\RangeSelectResult.sqf"";";
	};
	class PN_Button_Cancel: RscButton
	{
		idc = 1601;
		text = "Cancel"; //--- ToDo: Localize;
		x = 0.567031 * safezoneW + safezoneX;
		y = 0.665 * safezoneH + safezoneY;
		w = 0.04125 * safezoneW;
		h = 0.055 * safezoneH;
		action = "closeDialog 0";
	};
	////////////////////////////////////////////////////////
	// GUI EDITOR OUTPUT END
	////////////////////////////////////////////////////////
};
};

Share this post


Link to post
Share on other sites

Thanks for the input and I couldn't find the error in the .rpt but I did change the syntax to this | lbSetColor [1547,0,[1,0,0,1]]; and nothing happened. Also I did this hint format ["%1", lbColor[1547,0]]; and I get [1,0,0,1] but the color is still white when I reopen the lb.

Share this post


Link to post
Share on other sites

Works for me no problem:

[color="#FF8040"][color="#191970"][b]with[/b][/color] [color="#191970"][b]uiNamespace[/b][/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
ctrl [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]findDisplay[/b][/color] [color="#FF0000"]46[/color] [color="#191970"][b]ctrlCreate[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"RscListBox"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]-1[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
ctrl [color="#191970"][b]ctrlSetPosition[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]1[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]1[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
ctrl [color="#191970"][b]ctrlCommit[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color]
ctrl [color="#191970"][b]lbAdd[/b][/color] [color="#7A7A7A"]"hello"[/color][color="#8B3E2F"][b];[/b][/color]
ctrl [color="#191970"][b]lbAdd[/b][/color] [color="#7A7A7A"]"goodbye"[/color][color="#8B3E2F"][b];[/b][/color]
ctrl [color="#191970"][b]lbSetCurSel[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color]
ctrl [color="#191970"][b]lbSetColor[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#FF0000"]1[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]1[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

Share this post


Link to post
Share on other sites

Okay so I see what I was doing wrong. I would close the Dialog before I made the changes. Is there a way to change text color and make it stick for when the next time the display is called?

Share this post


Link to post
Share on other sites
Okay so I see what I was doing wrong. I would close the Dialog before I made the changes. Is there a way to change text color and make it stick for when the next time the display is called?

You can define whatever colours you want in config and they will stay every time you bring up dialog https://community.bistudio.com/wiki/DialogControls-ListBoxes

Share this post


Link to post
Share on other sites

So I found the answer to my solution. On my onLoad script file I basically looked for changes through variables and change the color of selected lbCurSel.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×