Jump to content
arma_max

ctrlChecked always returns FALSE

Recommended Posts

Hi,

 

I have a checkbox in my GUI

 

class checkboxCreateEmptyVehicle: RscCheckbox
		{
			idc = 2800;
			x = 0.341345 * safezoneW + safezoneX;
			y = 0.612847 * safezoneH + safezoneY;
			w = 0.015 * safezoneW;
			h = 0.03 * safezoneH;
		};

 

and when I click a button, it checks if that box is ticked or not:

 

_display = findDisplay	1234;
_ctrlCheckboxCreateEmptyVehicle = _display displayCtrl 2800;
_createEmptyVehicle = false;
_createEmptyVehicle = ctrlChecked _ctrlCheckboxCreateEmptyVehicle;

hint format ["_ctrlCheckboxCreateEmptyVehicle: \n%1", (ctrlChecked _ctrlCheckboxCreateEmptyVehicle)];

For some reason it is always returning FALSE, no matter whether I have ticked the box or not. What am I missing here?

Share this post


Link to post
Share on other sites

Thanks for the hint! Just added that and tried again, no difference!

The thing is, I am not getting any error messages or similar and all my other controls are working just fine. Its just that checkbox that won't work as expected.

 

 

Share this post


Link to post
Share on other sites

I found a workaround: set up the event handler on the checkbox to detect changes and store the value in a global variable. Not really sexy but it works …

 

control.hpp

onCheckedChanged = "[_this] execVM 'checkboxCreateEmptyVehicleCapture.sqf'";

 

checkboxCreateEmptyVehicleCapture.sqf:

_parms = _this select 0;
_ctrl = _parms select 0;
_intValue = _parms select 1;


if(_intValue == 1) then {
	checkboxCreateEmptyVehicleValue = true;
} else {
	checkboxCreateEmptyVehicleValue = false;
};

hint format ["_parms: \n%1", _parms];
hint format ["checkboxCreateEmptyVehicleValue: \n%1", checkboxCreateEmptyVehicleValue];

 

Share this post


Link to post
Share on other sites

I am an idiot. Of course you have to use cbChecked and not ctrlChecked when working with CT_CHECKBOX type 77 ... now its working as expected 🙂

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

×