Home   Help Search Login Register  

Author Topic: Detecting Selection within a list  (Read 1607 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
Detecting Selection within a list
« 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:
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Detecting Selection within a list
« Reply #1 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)

Offline ModestNovice

  • Members
  • *
Re: Detecting Selection within a list
« Reply #2 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?
« Last Edit: 25 May 2008, 06:55:51 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Detecting Selection within a list
« Reply #3 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.

Offline ModestNovice

  • Members
  • *
Re: Detecting Selection within a list
« Reply #4 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
« Last Edit: 01 Jun 2008, 04:29:11 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Detecting Selection within a list
« Reply #5 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]];

Offline ModestNovice

  • Members
  • *
Re: Detecting Selection within a list
« Reply #6 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.
« Last Edit: 01 Jun 2008, 18:18:14 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley