Jump to content
gc8

How to apply colors to script created button

Recommended Posts

hi

I have this problem that whenever I create button via script it doesnt look like the buttons I created from the editor..

 

here's the code I use:

 

_researchCfg2 = missionConfigFile >> "ResearchMenu" >> "controls";
_renum2 = getNumber (_researchCfg2 >> "idc");
_button = _display ctrlCreate ["RscButton", 1234, _display displayCtrl _renum2];
_button ctrlSetPosition [0,0, 0.3,0.1];
_button ctrlsettext format["test"];
_button ctrlCommit 0;

 

the button is gray while all rest of my buttons are green

 

anyone knows how to fix this?

 

thx

Share this post


Link to post
Share on other sites

Try ctrlSetBackgroundColor or look through the other GUI commands.

 

thx but I have tried that and these commands which seem to do nothing:

 

_button ctrlSetForegroundColor [1, 0, 0, 1];
_button ctrlSetActiveColor [1, 0, 0, 1];
_button ctrlSetBackgroundColor [1, 0, 0, 1];

Share this post


Link to post
Share on other sites

I can't remember if you needed to do this, but did you run ctrlCommit after?

 

yeah. here's my full code so far.

 

_researchCfg2 = missionConfigFile >> "ResearchMenu" >> "controls";
_renum2 = getNumber (_researchCfg2 >> "idc");
_button = _display ctrlCreate ["RscButton", 1234, _display displayCtrl _renum2];
_button ctrlSetPosition [0,0, 0.3,0.1];
_button ctrlsettext format["test"];
_button ctrlSetTextColor [1, 0, 0, 1];
_button ctrlSetForegroundColor [1, 0, 0, 1];
_button ctrlSetActiveColor [1, 0, 0, 1];
_button ctrlSetBackgroundColor [1, 0, 0, 1];
_button ctrlCommit 0;

the only thing changes is the text color to red....

Share this post


Link to post
Share on other sites

Ran to this problem again, still no idea how to make ctrlCreate created control change color. Tried changing the color in RscButton (Base class) as well but to no avail.

 

any ideas?

 

thx!

Share this post


Link to post
Share on other sites
5 minutes ago, pierremgi said:

What's your _display?

 

display is:

_display = findDisplay 44444;

and control group i'm creating the buttons in is:

_cont = _display displayCtrl 2300;

then I create the buttons:

_ctrl = _display ctrlCreate ["RscButton", 1200 + _x + _y * 10 ,  _cont];

Share this post


Link to post
Share on other sites
14 minutes ago, pierremgi said:

https://feedback.bistudio.com/T78904

 

It seems you should use the description.ext / config.cpp to create  your button.

 

the dialog .h file is included from description.ext.

 

I guess this is a bug and there's nothing we can do now.

Share this post


Link to post
Share on other sites

Have you tried renaming your class?  It may be trying to load details defined in the main config-file (RscButton) rather than your redefined version in the description file.

  • Thanks 1

Share this post


Link to post
Share on other sites
9 minutes ago, das attorney said:

Have you tried renaming your class?  It may be trying to load details defined in the main config-file (RscButton) rather than your redefined version in the description file.

 

that seems to be it!

by creating custom base class I was able to change the button's color. :)

 

script command still wont work for changing the color but this is all I need.

 

thanks!

  • Like 1

Share this post


Link to post
Share on other sites
Quote

NOTE: Since Arma 3 v1.69.141213 ctrlCreate will also search for control class in mission config, if search in the main config failed. This means one can now define classes in mission config and use them with ctrlCreate

Use "RscButtonMenu" instead.

disableSerialization;

_display = (findDisplay 46) createDisplay "RscDisplayEmpty";

_button =  _display ctrlCreate ["RscButtonMenu", 100];
_button ctrlSetPosition [(0.45 * safezoneW + safezoneX), (0.36 * safezoneH + safezoneY), (0.1 * safezoneW), (0.04 * safezoneH)];
_button ctrlSetBackgroundColor [1, 0, 0, 1];
_button ctrlCommit 0;

 

  • Like 1

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

×