Jump to content

Recommended Posts

Hi, im trying to make a list, i create the dialog, and its all okey, but when i try to select anything from the list, i make a hint reporting the index and the text, and the index in all the cases is -1, is like when i select an menu option, and it doesent select, any idea, for why it happends. Here is the code:

createDialog "cuerposDiag";

_display = findDisplay 7726;

_lista = _display displayCtrl 5245;
_boton = _display displayCtrl 1600;

_arrayCuerpos = [
	"Cuerpo1",
	"Cuerpo2",
	"Cuerpo3",
	"Cuerpo4",
	"Cuerpo5"
];

lbClear _lista; //Limpio la lista.


_indexArray = 0;

while {_indexArray < (count _arrayCuerpos)} do {
	_lista lbAdd (_arrayCuerpos select _indexArray);
	_lista lbSetData [_indexArray, (_arrayCuerpos select _indexArray)];
	_indexArray = _indexArray + 1;
};

index = lbCurSel _lista;
getLbText = _lista lbText index;
life_fnc_boton = {
	if (index == -1) exitWith {
		hint "No has seleccionado ninguna opción";
	};

	hint format ["%1 | %2", getLbText, index];
};


_boton buttonSetAction '[] call life_fnc_boton;';
	

 

Share this post


Link to post
Share on other sites

Hi. Replace this part of code with this and it should work (not tested). Do you need explanation ?
 

//index = lbCurSel _lista;
//getLbText = _lista lbText index;
life_fnc_boton = {
                  _display = findDisplay 7726;
                  _lista = _display displayCtrl 5245;
                  _index = lbCurSel _lista;
                  _getLbText = _lista lbText _index;
	if (_index == -1) exitWith {
		hint "No has seleccionado ninguna opción";
	};

	hint format ["%1 | %2", _getLbText, _index];
};

 

  • Like 2

Share this post


Link to post
Share on other sites
28 minutes ago, soldierXXXX said:

Hi. Replace this part of code with this and it should work (not tested). Do you need explanation ?
 


//index = lbCurSel _lista;
//getLbText = _lista lbText index;
life_fnc_boton = {
                  _display = findDisplay 7726;
                  _lista = _display displayCtrl 5245;
                  _index = lbCurSel _lista;
                  _getLbText = _lista lbText _index;
	if (_index == -1) exitWith {
		hint "No has seleccionado ninguna opción";
	};

	hint format ["%1 | %2", _getLbText, _index];
};

 

It works, thanks mate! I've trying it some days and you give me the answer, thanks!

  • Like 1

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

×