Jump to content
sizraide

RscListBox confusion...

Recommended Posts

Hello, I'm creating a singleplayer mission.

I wan't to add a notebook system where a player can press a key "N" and it would open a notebook GUI interface where the player can read their notes they've acquired throughout the mission.

I'm in the process of trying to add notes into the ListBox here:

notes.sqf

// Notes
createDialog "notes";

{
	private _noteName = _x;
	_ctrl = lbAdd [1500, _noteName];
} forEach ["Unfortunate Syrta", "FIA's purpose"];


But I am so confused. How do I make it so when a player clicks on an item in the list box it opens up a new display interface? Because I created multiple RscStructuredText classes for each note to display when a "note" is clicked inside the list box.

I've read the GUI configuration page for List boxes multiple times but I am still confused on the lbAdd, lbSetPicture, etc... commands.

My first attempt was to create a ButtonClick ctrlHandler that would activate when an item is clicked inside the list box, I still haven't been able to write the script for that yet. No idea if it would work.

Any help is appreciated, thanks.

 

Share this post


Link to post
Share on other sites
On 12/2/2021 at 6:44 PM, sizraide said:

ow do I make it so when a player clicks on an item in the list box it opens up a new display interface?

You can use the LBSelChanged UIEH for that

 

On 12/2/2021 at 6:44 PM, sizraide said:

My first attempt was to create a ButtonClick ctrlHandler that would activate when an item is clicked inside the list box, I still haven't been able to write the script for that yet.

You can only use a button UIEH on a button. Listboxes are not buttons.

 

On 12/2/2021 at 6:44 PM, sizraide said:

_ctrl = lbAdd [1500, _noteName];

lbAdd does not return a control. it returns the index of the added entry. also: using the first syntax instead of the second one is unreliable.

Share this post


Link to post
Share on other sites
On 12/3/2021 at 9:06 PM, 7erra said:

You can use the LBSelChanged UIEH for that

 

You can only use a button UIEH on a button. Listboxes are not buttons.

 

lbAdd does not return a control. it returns the index of the added entry. also: using the first syntax instead of the second one is unreliable.


Okay, I managed to fix everything so far and reach my end goal. I just have on issue

 

with uiNamespace do 
{
	ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", 2000];
	ctrl ctrlSetPosition [0.398398 * safezoneW + safezoneX , 0.211 * safezoneH + safezoneY, 0.322734 * safezoneW, 0.663 * safezoneH];
	ctrl ctrlSetFont "EtelkaMonospacePro";
	ctrl ctrlCommit 0;
	ctrl ctrlSetBackgroundColor [0,0,0,0.7];
};

 

When I try to access "ctrl" variable it does not get recognized in other scripts, how can I access it?

Share this post


Link to post
Share on other sites

you have to get the variable from uiNamespace with getVariable

Share this post


Link to post
Share on other sites
6 hours ago, 7erra said:

you have to get the variable from uiNamespace with getVariable


I haven't had any luck with using it because I have no clue on how to use it.

Could you give me an example of it being used? Thanks.

Share this post


Link to post
Share on other sites
uiNamespace getVariable "ctrl"

though I would suggest you choose another variable name, since this name is easily overwritten

Share this post


Link to post
Share on other sites
On 12/6/2021 at 12:43 AM, 7erra said:

uiNamespace getVariable "ctrl"
 

though I would suggest you choose another variable name, since this name is easily overwritten


I appreciate the help, sorry for the long replies I get caught up in work.

But is there any possible way to keep a dialog/display open after the person presses ESC? So the person can still access the main menu but the dialog will remain opened.

Share this post


Link to post
Share on other sites
18 hours ago, 7erra said:

yes, with https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onKeyDown

what main menu? the one you see at the start of the game?


KeyDown doesn't seem to work here? No errors pop up when I press ENTER button.

 

with uiNamespace do {
	[] spawn 
	{
		textDisplay = findDisplay 46 ctrlCreate ["RscStructuredText", 1100];
		textDisplay ctrlSetPosition [0.380469 * safezoneW + safezoneX, 0.534 * safezoneH + safezoneY, 0.227109 * safezoneW, 0.102 * safezoneH];
		textDisplay ctrlSetBackgroundColor [0,0,0,1];
		textDisplay ctrlSetText "All choices you pick will shape your character in the story for the whole mission, pick wisely.";
		textDisplay ctrlSetFontHeight 0.035;
		textDisplay ctrlCommit 0;

		buttonDisplay = findDisplay 46 ctrlCreate ["RscButton", 1600];
		buttonDisplay ctrlSetPosition [0.380469 * safezoneW + safezoneX, 0.636 * safezoneH + safezoneY, 0.227109 * safezoneW, 0.051 * safezoneH];
		buttonDisplay ctrlSetBackgroundColor [0,0,0,0.5];
		buttonDisplay ctrlSetText "Press 'ENTER' to confirm";
		buttonDisplay ctrlSetFontHeight 0.035;
		buttonDisplay ctrlCommit 0;
	};
};

(findDisplay 46) displayAddEventHandler ["keyDown",
{
	switch (_this select 1) do 
	{
		case 28:  
		{
			{ ctrlDelete (uiNamespace getVariable _x) } forEach [buttonDisplay, textDisplay]; 
			findDisplay 46 displayRemoveAllEventHandlers "KeyDown";
		}; 
		case 156:  
		{
			{ ctrlDelete (uiNamespace getVariable _x) } forEach [buttonDisplay, textDisplay]; 
			findDisplay 46 displayRemoveAllEventHandlers "KeyDown";
		};	
	};
	false
}];

 

Share this post


Link to post
Share on other sites
4 hours ago, sizraide said:

buttonDisplay, textDisplay

put those into quotes

 

4 hours ago, sizraide said:

findDisplay 46 displayRemoveAllEventHandlers "KeyDown";

really bad idea to use displayRemoveAllEventHandlers on the mission display. this will mess up all the other scripts that added an UIEH to it. better save the return from displayAddEventhandler and use displayRemoveEventhandler with it.

Share this post


Link to post
Share on other sites
3 hours ago, 7erra said:

put those into quotes

 

really bad idea to use displayRemoveAllEventHandlers on the mission display. this will mess up all the other scripts that added an UIEH to it. better save the return from displayAddEventhandler and use displayRemoveEventhandler with it.


Fixed, appreciate it.

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

×