OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ModestNovice on 25 May 2008, 00:27:40

Title: Detecting Selection within a list
Post by: ModestNovice on 25 May 2008, 00:27:40
Hello. I have 3 dialogs with listboxes. But I am having trouble figuring out how I can find out what was selected in the list when my button is pressed. Any help?  :dunno:
Title: Re: Detecting Selection within a list
Post by: Mandoble on 25 May 2008, 01:26:50
Use onLBSelChanged UI Event handler.

Inside your list box definition in description.ext add
Code: [Select]
         onLBSelChanged = "res = _this execVM ""item_selected.sqf""";

_this inside item_selected.sqf has the control (the listbox) in (_this select 0) and the selected item index (_this select 1)
Title: Re: Detecting Selection within a list
Post by: ModestNovice on 25 May 2008, 02:16:46
Thanks! Exactly what I needed  :good:

So how could I have it do something different for each selection.

I have the selections set through like lbsetData or sumthin. I know I have it execute a script, will it automatically? as for I have set the classname of the vehicle in the selection. like Skoda and car_sedan. Just using the select 0? will it detect what to create?
Title: Re: Detecting Selection within a list
Post by: Mandoble on 31 May 2008, 15:33:20
You need to discriminate what to do inside the function or script executed by the onLBSelChanged handler. You will get as parameter the index of the selected item so you can get its text and/or data and then decide what to do with it withing that script or function.
Title: Re: Detecting Selection within a list
Post by: ModestNovice on 01 Jun 2008, 01:20:37
Okay thanks

How do I do a variable in a ctrlsetText

like:
Code: [Select]
ctrlSetText [103, "DCV_Bank"];

I am trying to make my balance show on the dialog
Title: Re: Detecting Selection within a list
Post by: Mandoble on 01 Jun 2008, 07:45:36
If you mean to show the content of a variable, convert it to string with format command.
ctrlSetText [103, format["%1", DCV_Bank]];
Title: Re: Detecting Selection within a list
Post by: ModestNovice on 01 Jun 2008, 18:12:40
ahhh ok. I thought it would be something like a formatted thing. Only, what do I use this in? A static text I'm assuming?
Thanks for the help Mandoble.

Also, sweeeeett fountain script. I have been waiting for a script like this so I can do somewhat of a firefighting job. only thing is I don't know exactly how I could do burning buildings, maybe particles, or create a destroyed object inside and make it look like it's burning? I don't know.