Jump to content

Recommended Posts

OK I have populated my ComboBox

 

{
_index = lbAdd [2100, _x];
} forEach ["Combo 1","Combo 2","Combo 3"];

And i see the list yaaaaaaa > when I make a selection  then click on the apply button it fires this >

 

Hint "Yep we got here OK ";  /// see if we get here
private ["_data"];
_data = lbData [ 2100, lbCurSel 2100 ];
player sideChat format ["%1", _data];

 

I get the hint but never get the side chat of my selection  , I thought it would pass a 0,1,2  depending on my selection ?

 

Any help would be awesome as been trying all day on this  

Share this post


Link to post
Share on other sites

Do you have a radio equipped? Sidechat won't work without one. Use systemchat instead.

Also make sure to return a default value in case _data is not defined:

Hint "Yep we got here OK ";  /// see if we get here
private ["_data"];
_data = lbData [ 2100, lbCurSel 2100 ];
_check = if (_data isEqualTo "") then {"Error"} else {_data};
systemChat format ["%1", _check];

 

Cheers

Share this post


Link to post
Share on other sites

Yes i have a radio  but I must be doing something wrong as I now always get "error"

 

If i HINT STR(_data);    i get ""

 

Am I filling the combo correct -  as I am lost as to why I cannot get the selected value   ?

 

Thanks

 

This is my test GUI i am working on :-

 

https://drive.google.com/file/d/0B3cKXZRr8-B3RGxXSXZFeHRlRnc/view?usp=sharing

Share this post


Link to post
Share on other sites

Found it:

 

lbSetData only accepts strings. Numbers are ignored.

// File: populate.sqf, line 11-18
// WRONG:
{
	_index = lbAdd [ 1500, ( _x select 0 ) ];
	lbSetData [ 1500, _index, ( _x select 1 ) ];
} forEach [
	["Item1",0],
	["Item2",1],
	["Item3",2]
];

//////////////////////////////////////////////////////

// RIGHT:
{
	_index = lbAdd [ 1500, ( _x select 0 ) ];
	lbSetData [ 1500, _index, str ( _x select 1 ) ];
} forEach [
	["Item1",0],
	["Item2",1],
	["Item3",2]
];

Just add "str" to your script. If you want a number again use parseNumber.

 

EDIT:

And also, your ListBox IDC is 1500 not 2100 ;)

Edited by 7erra

Share this post


Link to post
Share on other sites

ahhh just run it it works perfect !

 

Many thanks for finding the issue a true gent  :)

 

*  the listbox was there for testing i should have removed that !

 

*Also i was closing the Dialog hence there was nothing being returned ! DOH

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

×