Elemtael 1 Posted July 26, 2018 After much head banging I have decided its time to ask the experts... In a nutshell I am trying to write a script using using a dialog to create garage functionality for the players with integration of INIDBI2. I've worked out how to get the dialog created and populated from the databasae but for the life of me I cannot figure out how to identify what the player has selected. Any tinkering and hinting I have done is returning either an empty value (I suspect its hidden) or -1. Appreciate any help I can get with this one. +++ loadVehicleList.sqf+++ disableSerialization; _inidbi2 = ["new", "Faction Database"] call OO_INIDBI; _garArray = ["read", ["Logistics", "Garage"]] call _inidbi2; createDialog "garageMenu"; waitUntil {!isNull (findDisplay 9998);}; disableSerialization; { private ["_index"]; _index = lbAdd [1500, _x]; lbSetData [1500, _index, _x]; player sideChat format [" Index is %1. _x is %2", _index, _x]; } forEach _garArray; lbSetCurSel [ 1500, 0 ]; +++selectVehicle.sqf+++ disableSerialization; _ctrl = (findDisplay 9998) displayCtrl 1500; _selection = _ctrl lbText (lbCurSel _ctrl); P.S. I am aware there are existing examples of this but I have had a hard time digging through them. I'm also doing this to learn so copy pasta is not an option :( Share this post Link to post Share on other sites
gokitty1199 225 Posted July 26, 2018 https://community.bistudio.com/wiki/lbCurSel if you have a string in the lb https://community.bistudio.com/wiki/lbData or with the lb int https://community.bistudio.com/wiki/lbValue Share this post Link to post Share on other sites
Elemtael 1 Posted July 26, 2018 lbCurSel is returning -1 which the article comments define as nothing selected. Could it be because I am populating the list via an array? Share this post Link to post Share on other sites
gokitty1199 225 Posted July 27, 2018 1 hour ago, Elemtael said: lbCurSel is returning -1 which the article comments define as nothing selected. Could it be because I am populating the list via an array? i fill mine with forEach and arrays { _wepName = getText (configFile >> "cfgWeapons" >> _x >> "displayname"); lbAdd [1500, _wepName]; lbSetData [1500, _forEachIndex, _x]; } forEach _rifles; _slot = lbCurSel 1500; selWeapon = lbData [1500, _slot]; Share this post Link to post Share on other sites
Elemtael 1 Posted July 27, 2018 Hmmm still missing something. Thank you for the getText bit though. Looks a lot better than staring at classnames :D _slot is still returning -1 (my understanding is this is supposed to be the index of the listbox item selected with -1 meaning nothing is selected. Why is nothing selected? I can see the gray highlight with something selected) and the selWeapon bit is returning a nonexistent entry (blank) which I suppose is to be expected if the index bit is not working. The way I have it set currently is to populate the list when it is opened from one script, then I have a select button that fires to get what the player has selected in another. Is that the right way to do it or is there a better alternative? I do appreciate the help kitty. Latest bits: +++loadVehicleList.sqf+++ disableSerialization; _inidbi2 = ["new", "Faction Database"] call OO_INIDBI; _garArray = ["read", ["Logistics", "Garage"]] call _inidbi2; createDialog "garageMenu"; waitUntil {!isNull (findDisplay 9998);}; disableSerialization; { _vehName = getText (configFile >> "cfgVehicles" >> _x >> "displayname"); lbAdd [1500, _vehName]; lbSetData [1500, _forEachIndex, _x]; } forEach _garArray; selectVehicle.sqf disableSerialization; _index = lbCurSel 1500; player sideChat format ["Variable is %1", _index]; selVehicle = lbData [1500, _index]; player sideChat format ["Variable is %1", selVehicle]; Share this post Link to post Share on other sites
HazJ 1288 Posted July 27, 2018 What does _index return? Output it? Always -1? Try further debugging: (_display displayCtrl IDC) ctrlAddEventHandler ["LBSelChanged", { params ["_ctrl", "_index"]; _display = uiNamespace getVariable "xxx"; // or use findDisplay IDD hintSilent format ["Selected: %1", lbCurSel _ctrl]; }]; Adjust accordingly. Share this post Link to post Share on other sites
Elemtael 1 Posted July 27, 2018 I got it working. I realized that in the 2nd script the dialog did not exist so I added an event handler via the first script for when the select button is used. And painfully I now realize why you used the global variables *facepalm* Share this post Link to post Share on other sites