Jump to content
Erwin23p

[GUI] trying to clear a structured text...

Recommended Posts

Hi, I'm working on a little script that has a listbox, a button and an structured text, when you select an item of the list box it calls a function that displays some info about the selection on the structured text, all good for now. But the problem comes when I run out of items in my list box, I can't clear some of the text, the only solution I found is close the dialog and reopen it again.

I'm using this to write my text:

Spoiler

_ctrltext = ((findDisplay 501) displayCtrl (1101));
_ctrltext ctrlSetStructuredText parseText format [
	"<t align='center'>%1 info</t><br/><t align='left'>Supplies: %2<br/>Cargo: %3</t>",_supplyName, _currentSupplies,_cargo];

 

and tried:

Spoiler

_ctrltext ctrlSetStructuredText parseText format [""];

also:


_ctrltext ctrlSetStructuredText parseText "<br/>";

 

 

Share this post


Link to post
Share on other sites

Have you just tried using:

 

_ctrltext ctrlSetStructuredText parseText "";

 

Seems like that should work? That'd be my first guess anyway. 

  • Like 2

Share this post


Link to post
Share on other sites

I don't think you need to parse it if it is an empty string. Try:

_ctrltext ctrlSetStructuredText "";

 

Share this post


Link to post
Share on other sites

If it doesn't work it doesn't work. Key words, try and I didn't say a string was structured text. Maybe instead of replying with such a pointless post, actually help contribute ?

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, HazJ said:

Maybe instead of replying with such a pointless post, actually help contribute ?

Maybe instead of replying with a non working script and the call for the threat author to waste the time trying something that doesn't work, actually check if it works first? Its just a 5 second read of the wiki anyway.

 

beno's tip should work, if not check that _ctrltext is valid, which I assume it is, besides that I'm out of ideas.

  • Haha 1

Share this post


Link to post
Share on other sites

@beno_83au's solution works. Also ctrlSetText "" works as well. Both tested.

Share this post


Link to post
Share on other sites
On 3/23/2020 at 4:37 AM, beno_83au said:

Have you just tried using:

 

_ctrltext ctrlSetStructuredText parseText "";

 

Seems like that should work? That'd be my first guess anyway. 

That worked just fine, thanks! 
But what is the main difference with what I tried? And why mine didn't work?

_ctrltext ctrlSetStructuredText parseText format [""];

  • Like 1

Share this post


Link to post
Share on other sites

You aren't passing anything to format. Perhaps this would work but completely unnecessary. Not tested.

_ctrltext ctrlSetStructuredText parseText format ["", nil];

  • Thanks 1

Share this post


Link to post
Share on other sites

Hello again, I have a new problem:

I'm working on an hud menu style, not a dialog but a display kind:

Init:

Spoiler

(findDisplay 46) displayAddEventHandler ["KeyDown", {

        _key = _this # 1;

        if (_key in actionKeys "reloadMagazine" && !(missionNamespace getVariable ["elca_reloadDown", false])) then {

            elca_reloadDown = true;

            [] spawn {

                _t = time + 1;

                waitUntil {!elca_reloadDown OR time >= _t};

                if (time < _t) then {

                    reload player;

                } else {

                    if (elca_reloadDown) then {

                        call elca_fnc_radioMenu;

                    };

                };

            };

        };

    }];

 

This works just fine.

IF radioOpen function is this:

Spoiler

elca_pressedRadio = false;

disableSerialization;

//UI

_display = findDisplay 46;

_menu = _display ctrlCreate ["RscStructuredText", -1];

_menu ctrlSetBackgroundColor [0,0,0,0.4];

_menu ctrlSetTextColor [1,1,1,0.9];

_menu ctrlSetStructuredText parseText "<t align='left' valign='middle' size='1.1'>

1 Permissión para despegar<br/>

2 Reportar al comandante</t>";

_menu ctrlSetPosition [0.5,0.3,ctrlTextWidth _menu,0.15];



_menu ctrlCommit 0;

 

 but as soon as I add this to the function, when I open radioOpen (press R) I loose all keyboard Ui input:

Spoiler

_menuControl = (findDisplay 46) displayAddEventHandler ["KeyDown", {
		_key = _this # 1;
		switch (_key) do {
		case 2: {	
			elca_pressedRadio = true;
			//["introduction","elca_fnc_dialog"] call elca_fnc_ejecutar;
		};
		case 3: {	
			elca_pressedRadio = true;
			//["atc_takeOff","elca_fnc_dialog"] call elca_fnc_ejecutar;
		};
	};
}];

 

I tried a bunch of things, I also had some spawn functions inside the "case 2:" but I simplified everything just to fix the main error.

Share this post


Link to post
Share on other sites

At the end of a KeyDown UIEH always return false:

_display displayAddEventhandler ["KeyDown",{
	/* code */
	false
};

Otherwise you are overwriting the default behaviour of that key, or in other words, intercept any following input.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks a lot! I got it working, I did read that on the bis wiki but I didn't fully understand it... 

Share this post


Link to post
Share on other sites

Hi, I have a new problem, tried a lot of things but can't get it working.

I'm still with the HUD menu, it has to be with display because it's intended to use when flying so you don't have to lose controls.

I have a menu with a listbox: 

Spoiler

elca_selectedAtc = false;
atcOptions = ["startEngines","taxiToRunway","taxiToInfantry","takeOff","approach","land","mayday"];
_atcTimer = time + 10;


disableSerialization;
_display = findDisplay 46;
_atcMenu = _display ctrlCreate ["RscListbox", 501];
_atcMenu ctrlSetBackgroundColor [0,0,0,0.4];
_atcMenu ctrlSetTextColor [1,1,1,0.9];
{
	if (player getVariable [_x, false]) then 
	{
		_index = _atcMenu lbAdd (_x);
		_atcMenu lbSetValue [(lbSize _atcMenu) -1, _forEachIndex];
	};
} forEach atcOptions;
_atcMenu ctrlSetPosition [0.5,0.3,0.2,0.05 * (lbSize _atcMenu)];
_atcMenu ctrlCommit 0;
player setVariable ["atcMenu", true];

 

Then the display EH to select an option:

Spoiler

atcControl = (findDisplay 46) displayAddEventHandler ["KeyDown", {
		_key = _this # 1;
		switch (_key) do {
		case 2: {
			elca_selectedAtc = true;
			_index = lbValue [501, 0];
			_function = atcOptions select _index;
			hint _function;
			["ATC",_function] execFSM "fsm\radioManager.fsm";
		};
		case 3: {	
			elca_selectedAtc = true;
			_index = lbValue [501, 1];
			_function = atcOptions select _index;
			["ATC",_function] execFSM "fsm\radioManager.fsm";
			};
		case 4: {	
			elca_selectedAtc = true;
			_index = lbValue [501, 2];
			_function = atcOptions select _index;
			["ATC",_function] execFSM "fsm\radioManager.fsm";
		};
	};
	false
}];

 

then, for closing the script:

Spoiler

waitUntil {time >= _atcTimer OR elca_selectedAtc};
if (time >= _atcTimer) then {
	_atcMenu ctrlSetFade 1;
	_atcMenu ctrlCommit 1.5;
	sleep 1;
	lbClear _atcMenu;
	ctrlDelete _atcMenu;
	(findDisplay 46) displayRemoveEventHandler ["KeyDown", atcControl];
	player setVariable ["radioMenu", false];
} else {
	lbClear _atcMenu;
	ctrlDelete _atcMenu;
	(findDisplay 46) displayRemoveEventHandler ["KeyDown", atcControl];
	player setVariable ["radioMenu", false];
};

 


So, I have a problem with 2 menus like this I have and it's when I choose an option, let's say option 1, it's variable "startEngines" on the atcOptions array, so there is a script in the FSM that does this:

player setVariable ["startEngines", false];

so next time I open this same menu, this variable shouldn't appear on the listbox right? So all good, it doesn't apper, the problem comes when I summon:

case 2: {
			elca_selectedAtc = true;
			_index = lbValue [501, 0];
			_function = atcOptions select _index;
			hint _function;
        };

it always give me the menu I deleted value, even if a I select option 2 (case 3, index 1) it gives me "startEngines" always...

I've been all the day testing... what is my problem here?

Share this post


Link to post
Share on other sites

After reading over and over my script, looking at all the commands/functions I'm using where the problem is, I think the main problem is with the lbSetValue, lbValue. It works only for dialogs I think, so my solution is this:

Spoiler

elca_selectedAtc = false;
atcOptions = ["startEngines","taxiToRunway","taxiToInfantry","takeOff","approach","land","mayday"];
_atcTimer = time + 10;
atcActiveOptions = [];

disableSerialization;
_display = findDisplay 46;
_atcMenu = _display ctrlCreate ["RscListbox", 501];
_atcMenu ctrlSetBackgroundColor [0,0,0,0.4];
_atcMenu ctrlSetTextColor [1,1,1,0.9];
{
	if (player getVariable [_x, false]) then 
	{
		atcActiveOptions pushback _x;
		private _index = _atcMenu lbAdd (_x);
		/*_atcMenu lbSetValue [_index, _forEachIndex];
		hint format ["%1 is true", _forEachIndex];
		sleep 1;*/
	};
} forEach atcOptions;
_atcMenu ctrlSetPosition [0.5,0.3,0.2,0.05 * (lbSize _atcMenu)];
_atcMenu ctrlCommit 0;
player setVariable ["atcMenu", true];

_atcControl = (findDisplay 46) displayAddEventHandler ["KeyDown", {
		_key = _this # 1;
		switch (_key) do {
		case 2: {
			elca_selectedAtc = true;
			//private _index = lbValue [501, 0];
			private _function = atcActiveOptions select 0;
			hint _function;
			["ATC",_function] execFSM "fsm\radioManager.fsm";
		};
		case 3: {	
			elca_selectedAtc = true;
			private _index = lbValue [501, 1];
			private _function = atcOptions select _index;
			hint _function;
			["ATC",_function] execFSM "fsm\radioManager.fsm";
			};
		case 4: {	
			elca_selectedAtc = true;
			private _index = lbValue [501, 2];
			private _function = atcOptions select _index;
			["ATC",_function] execFSM "fsm\radioManager.fsm";
		};
	};
	false
}];

waitUntil {time >= _atcTimer OR elca_selectedAtc};
if (time >= _atcTimer) then {
	_atcMenu ctrlSetFade 1;
	_atcMenu ctrlCommit 1.5;
	sleep 1;
	lbClear _atcMenu;
	ctrlDelete _atcMenu;
	(findDisplay 46) displayRemoveEventHandler ["KeyDown", _atcControl];
	player setVariable ["radioMenu", false];
} else {
	lbClear _atcMenu;
	ctrlDelete _atcMenu;
	(findDisplay 46) displayRemoveEventHandler ["KeyDown", _atcControl];
	player setVariable ["radioMenu", false];
};

 

 

I create an empty array, and when one string of the main array turns true, it sends it to the new array, and the order of the listbox is the same as the commands so, Lb index 0, will always be the new array index 0.

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

×