Hi,
I'm trying to retrieve the index of the selected value of a listBox. The problem is that
lbCurSel returns a
scalar value and
lbSelection returns a value
array. Shouldn't both of them return an integer, e. g. 0 if the very first element of the listBox is selected?
The listBox is defined like this (using
Dr_Eyeball's dialog framework):
class RscLB_LIST
{
// type = defined in derived class
idc = -1;
style = ST_LEFT;
x = 0.1;
y = 0.1;
w = 0.2;
h = Dlg_CONTROLHGT;
sizeEx = Dlg_TEXTHGT;
rowHeight = Dlg_TEXTHGT;
color[] = {Dlg_Color_White,1};
colorText[] = {Dlg_ColorScheme_WindowText,1};
colorBackground[] = {Dlg_ColorScheme_WindowBackground, 1}; // always clear?
colorSelect[] = {Dlg_ColorScheme_WindowText,1};
colorSelect2[] = {Dlg_ColorScheme_WindowText,1};
colorScrollbar[] = {Dlg_Color_White,1};
colorSelectBackground[] = {Dlg_ColorScheme_3DControlBackground,1};
colorSelectBackground2[] = {Dlg_ColorScheme_HighlightBackground,1};
font = FontM;
soundSelect[] = {"\ca\ui\data\sound\mouse3", 0.2, 1};
soundExpand[] = {"\ca\ui\data\sound\mouse2", 0.2, 1};
soundCollapse[] = {"\ca\ui\data\sound\mouse1", 0.2, 1};
autoScrollSpeed = -1;
autoScrollDelay = 5;
autoScrollRewind = 0;
maxHistoryDelay = 1.0;
class ScrollBar {
color[] = {1, 1, 1, 0.6};
colorActive[] = {1, 1, 1, 1};
colorDisabled[] = {1, 1, 1, 0.3};
thumb = "\ca\ui\data\igui_scrollbar_thumb_ca.paa";
arrowFull = "\ca\ui\data\igui_arrow_top_active_ca.paa";
arrowEmpty = "\ca\ui\data\igui_arrow_top_ca.paa";
border = "\ca\ui\data\igui_border_scroll_ca.paa";
};
};
class RscListBox: RscLB_LIST
{
type = CT_LISTBOX;
onLBSelChanged = "";
onLBDblClick = "";
};
class REQUEST_QUEUE_DIALOG {
movingEnable = 1;//--- The dialog window can be moved.
idd = 10001;
//onLoad = "ExecVM 'test.sqf'"; //--- Script loaded upon creation.
class controls {
class REQUEST_QUEUE : RscListBox {
idc = 10002;
x = 0.21375; y = 0.25889;
w = 0.475; h = 0.3;
};
};
I add items to the listBox like this:
for [{_i=0},{_i < count request_queue_list},{_i=_i+1}] do {
lbAdd [REQUEST_QUEUE, format[localize "STR_request_queue_entry", (request_queue_list select _i) select 0, (request_queue_list select _i) select 1, (request_queue_list select _i) select 2, (request_queue_list select _i) select 3,(request_queue_list select _i) select 4]]
};
request_queue_list is an array and I'm adding it's content into the listBox as formatted strings obviously.
So the entries of the listBox contains the elements of the
request_queue_list array in the same order but in string format.
I use lbCurSel or lbSelection like this:
hint format["%1", lbCurSel REQUEST_QUEUE];
hint format["%1", lbSelection REQUEST_QUEUE];
Can you help me to get the selected index of the listBox so I can retrieve the corresponding elements from the
request_queue_list array?
I'm not very experienced in dialog scripting and would appreciate any best practices you want to share because I'm not sure that the way I'm trying to work with the listBox (adding and retrieving items) is efficient.