Jump to content
xjoker_

problem with ctrlShow

Recommended Posts

Hello,

 

I have a problem with one of my dialogs, that's the first time it happens to me so I really don't understand what's wrong. 

It's very simple I have 3 RscButton and i want to hide them with for example 

(_d displayCtrl 2545) ctrlShow false;

it has no effect. The button is still here. 

Other commands such as ctrlEnable or ctrlSetText work though

(_d displayCtrl 2545) ctrlEnable false;

the button is disabled as expected. 

 

So I don't know. Is there a condition that has to be ok before using ctrlShow ? 

NB : it works when i do it inside a button event 

onButtonClick = "((ctrlParent (_this#0)) displayCtrl 2545) ctrlShow false;";

 

Share this post


Link to post
Share on other sites

This works for me, after an action like button click or coming from an event handler like ctrlAddEventHandler ("LBSelChanged" or else).

So, perhaps, you should think about when/how you call this command.

NB: A _ctrl ctrlCommit 0 could be a solution? not tested.

Share this post


Link to post
Share on other sites
 		_btn = (_d displayCtrl 2545);
 		diag_log format["shown : %1",ctrlShown _btn];
 		_btn ctrlShow false; 
 		diag_log format["shown : %1",ctrlShown _btn];

result : 

Quote

19:57:06 "shown : true"
19:57:06 "shown : false"

 

But he's still visible :eh:

 

7 minutes ago, pierremgi said:

This works for me, after an action like button click or coming from an event handler like ctrlAddEventHandler ("LBSelChanged" or else).

So, perhaps, you should think about when/how you call this command.

NB: A _ctrl ctrlCommit 0 could be a solution? not tested.

 

just tried with ctrlCommit, same issue :/

Share this post


Link to post
Share on other sites

So, in which context do you want it hidden? Do you have any event handler in your script which could host this line?

 

Example:

_yourDisplay displayAddEventHandler ["mouseMoving", "_this call {

  params ["_display"];
  disableSerialization;
  (_display displayCtrl 2545) crtlShow false;

}"];

Share this post


Link to post
Share on other sites

Hello,
i'm having the same issue trying to change control's text and text's color.

 

ctrlSetText and ctrlSetTextColor do work inside events (such as "action" or "onButtonClick"), but trying to change those settings outside my dialog's hpp has no effect at all.

What I'm doing is calling an sqf from the action event, and then from there I need to change some ctrl' stuff.

 

The control is returned successfully, I also tried command's alternative syntaxes, but still no luck. The button class is RscButton and the dialog is set as follows:

Spoiler

Dialog is created with alt+click on map.

Dialog.hpp

Spoiler


class marker_create
{
	idd = 18001;
	name = "marker_create";
	movingEnable = 0;
	onLoad = "uiNamespace setVariable ['rnd_marker', _this select 0]";
	onUnload = "";

	class rndMarker_side: RscButton
	{
		idc = 15005;
		text = "OPFOR";
		font = "PuristaMedium";
		sizeEx = 0.030;
        //action = "execVM 'side_button.sqf'"; -----> THIS
		//onButtonClick = "execVM 'side_button.sqf'"; -----> OR THIS
		colorText[] = {0.5,0,0,1};
		colorBorder[] = {1,1,1,0};
		colorBackground[] = {1,1,1,0};
		colorBackgroundActive[] = {1,1,1,0};
		colorFocused[] = {1,1,1,0};
		colorShadow[] = {1,1,1,0};
		shadow = 0;

		x = 0.500 * safezoneW + safezoneX;
		y = 0.500 * safezoneH + safezoneY;
		w = 0.050 * safezoneW;
		h = 0.025 * safezoneH;
	};
};

 


button.sqf
 


_map = (findDisplay 12 displayCtrl 51);
_control = ((findDisplay 18001) displayCtrl 15005);
//_control = (uiNamespace getVariable 'rnd_marker') displayCtrl 15005; doesn't work aswell

if (ctrlText 15005 == "OPFOR") then {
	
  ctrlSetText [15005, "BLUFOR"];
  _control ctrlSetTextColor [0,0.3,0.6,1];
  _control ctrlCommit 0;
};

 

 

Share this post


Link to post
Share on other sites

Up, also tried to execVM an external file from the event inside of the dialog's hpp and then to add a ctrlEH from there, but doesn't work!

Share this post


Link to post
Share on other sites

Where are you doing this? Please provide more code so I/others can help further. Example from Authority project:

// Check whether to show dev tools button or not
_display = uiNamespace getVariable ["disp_missionStatus", displayNull];
_devTools = _display displayCtrl IDC_MS_DEVTOOLS;
_uid = if (isMultiplayer) then {getPlayerUID player} else {000};
if !(_uid in authenticatedAdmins) then
{
	_devTools ctrlShow false;
};
// onLoad/onUnload:
onLoad = "uiNamespace setVariable [""disp_missionStatus"", param [0]]; _this call BIS_fnc_guiEffectTiles; [] spawn tky_fnc_missionStatus;";
onUnload = "uiNamespace setVariable [""disp_missionStatus"", nil];";

 

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

×