Jump to content
  • 0

Looking for some GUI help


hambeast

Question

Hey was wondering if any of you advanced arma coders in here could shed some light on a subject I've been wondering about for a time.

 

So I want to make a gui with dropdowns in game and I know how to do that see: http://forums.bistudio.com/showthread.php?98221-Dialogs-and-Listbox-Combobox-creation

 

The question I have is how do I get the data that is selected from those dropdowns.

 

Say I have a dropdown with "Apple", "Orange", "Bananna".  The user selects one and presses ok.  How would I retrieve that data?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Well this is how i do it.

 

Lets say you create a ListBox and you want to populate it with some data.

For example:

{
  _name = format["Potato %1", x];
  _index = _ListBox lbAdd _name;
  _ListBox lbSetData [_index, x];      
};
} forEach _arrayID;

lets say i have an array with Ids,

I populate the _ListBox which is basically a RscListBox with row like Potato 1, Potato 2 etc.

Then i set a hidden value to each row with lbSetData...which sets the index of the row, and then the hidden value....in this case the ID from the array.

So when a player selects row Potato 3 for example, i know he selected 3.

 

Now to retrieve the data selected ?

There are 2 ways...

One on your button (the OK button i mean) you can do :

onButtonClick = "call okPressedFunction;";

And in that script (you can do it like compiles.sqf does it...make a files and call compile it with name okPressedFunction) to this:

_dialog = findDisplay YourCustomDialogueName;
_ListBox = _dialog displayCtrl YourCustomListBoxClassHere;

_index = lbCurSel _ListBox;
_playerSelection = _ListBox lbData _index;

_ddata = call compile _playerSelection;  //this might not be necessary if its not an array....like in our case its just a number
_selectedID = _ddata select 0;  //here is the selection

The other way is in your .hpp file on your buttonclick to grab the selection from the listbox and send it to a script like this:

onMouseButtonClick = "[(lbCurSel 1806)] call okPressedFunction;";

where 1806 is the idc of the listbox
.The you just do _this select 0  in your okPressedFunction script  (or _this select 1...not sure) to grab the index from the Listbox

 

 

edit: crap .... lol

Link to comment
Share on other sites

  • 0

Well this is how i do it.

 

Lets say you create a ListBox and you want to populate it with some data.

For example:

{
  _name = format["Potato %1", x];
  _index = _ListBox lbAdd _name;
  _ListBox lbSetData [_index, x];      
};
} forEach _arrayID;

lets say i have an array with Ids,

I populate the _ListBox which is basically a RscListBox with row like Potato 1, Potato 2 etc.

Then i set a hidden value to each row with lbSetData...which sets the index of the row, and then the hidden value....in this case the ID from the array.

So when a player selects row Potato 3 for example, i know he selected 3.

 

Now to retrieve the data selected ?

There are 2 ways...

One on your button (the OK button i mean) you can do :

onButtonClick = "call okPressedFunction;";

And in that script (you can do it like compiles.sqf does it...make a files and call compile it with name okPressedFunction) to this:

_dialog = findDisplay YourCustomDialogueName;
_ListBox = _dialog displayCtrl YourCustomListBoxClassHere;

_index = lbCurSel _ListBox;
_playerSelection = _ListBox lbData _index;

_ddata = call compile _playerSelection;  //this might not be necessary if its not an array....like in our case its just a number
_selectedID = _ddata select 0;  //here is the selection

The other way is in your .hpp file on your buttonclick to grab the selection from the listbox and send it to a script like this:

onMouseButtonClick = "[(lbCurSel 1806)] call okPressedFunction;";

where 1806 is the idc of the listbox

.The you just do _this select 0  in your okPressedFunction script  (or _this select 1...not sure) to grab the index from the Listbox

 

 

edit: crap .... lol

 

that is a very well put together response.  I'll give this a go tonight and probably ask you a few questions tomorrow :)  Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...