Jump to content
_Winters_

getting data from RscXListBox?

Recommended Posts

As the title implies, I am trying to get data from a RscXListBox.

 

I have done a lot of googling to no avail.. 

 

The RscXListBox displays fine and allows me to page through the different selections I add with lbAdd fine, but I can't seem to select anything..

 

I have code that works with RscListBox and it gets the data fine, but with RscXListBox I always get -1 (no selection) returned when I use lbCurSel

 

Does lbCurSel not work with RscListBox? 

 

I wanted to use RscXListBox because it is only one list element high and looks cleaner on the dialog.. but if someone has a working example of RscListBox  which displays on one vertical line i'm open to using that instead.

 

Anyhow here is my define.. 

 

class RscXListBox
{
    access = 0;
    idc = CT_XLISTBOX;
    type = CT_XLISTBOX;
    style = SL_HORZ + ST_CENTER + LB_TEXTURES;
    default = 0;
    blinkingPeriod = 0;
    x = 12 * GUI_GRID_CENTER_W + GUI_GRID_CENTER_X;
    y = 17 * GUI_GRID_CENTER_H + GUI_GRID_CENTER_Y;
    w = 10 * GUI_GRID_CENTER_W;
    h = 1 * GUI_GRID_CENTER_H;
    color[] = {1,1,1,1};
    colorActive[] = {1,1,1,1};
    sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
    font = "PuristaMedium";
    shadow = 0;
    colorText[] = {1,1,1,1}; // Text color
    colorSelect[] = {0,1,1,1}; // Selected text color
    colorDisabled[] = {1,1,1,0.5}; // Disabled text color
    tooltip = ""; // Tooltip text
    tooltipColorShade[] = {0,0,0,0}; // Tooltip background color
    tooltipColorText[] = {1,1,1,0}; // Tooltip text color
    tooltipColorBox[] = {1,1,1,0}; // Tooltip frame color
    arrowEmpty = "\A3\ui_f\data\gui\cfg\slider\arrowEmpty_ca.paa"; // Arrow
    arrowFull = "\A3\ui_f\data\gui\cfg\slider\arrowFull_ca.paa"; // Arrow when clicked on
    border = "\A3\ui_f\data\gui\cfg\slider\border_ca.paa"; // Fill texture
    soundSelect[] = {"\A3\ui_f\data\sound\RscListbox\soundSelect",0.09,1};
};

 

Here is my definition from my dialogs file.. 

 

class clsOptionsHelicopterListbox: RscXListBox
{
    access = 0; // Control access (0 - ReadAndWrite, 1 - ReadAndCreate, 2 - ReadOnly, 3 - ReadOnlyVerified)
    idc = 1500;
    style = SL_HORZ + ST_CENTER + LB_TEXTURES; // Style
    x = 0.304062 * safezoneW + safezoneX;
    y = 0.698 * safezoneH + safezoneY;
    w = 0.139219 * safezoneW;
    h = 0.022 * safezoneH;
    onLBListSelChanged="hint str ['onLBSelChanged',_this]; false";
};

 

here is the code I use to load it when the dialog is initialized.. 

 

_HelicopterListbox = _dialog_control displayCtrl 1500;

 

hl_0 = _HelicopterListbox lbAdd "MH-9 Hummingbird";
hl_1 = _HelicopterListbox lbAdd "UH-80 Ghost Hawk";
hl_2 = _HelicopterListbox lbAdd "CH-67 Huron";
hl_3 = _HelicopterListbox lbAdd "V-44 X Blackfish";
hl_4 = _HelicopterListbox lbAdd "AH-99 Blackfoot";
hl_5 = _HelicopterListbox lbAdd "Mi-290 Taru";
hl_6 = _HelicopterListbox lbAdd "PO-30 Orca";
hl_7 = _HelicopterListbox lbAdd "Mi-48 Kajman";
hl_8 = _HelicopterListbox lbAdd "WY-55 Hellcat";
hl_9 = _HelicopterListbox lbAdd "CH-49 Mohawk";

lbSetCurSel [1500, hl_0];

 

And Finally here is the code I am using to try and get the value from it when the user hits ok on the dialog.. 

 


_HelicopterListBoxIndex = lbCurSel 1500;

hint format["_HelicopterListBoxIndex = %1",_HelicopterListBoxIndex];

 

I currently always get -1 .. grr any help would really be appreciated.. 

 

 

 

 

Share this post


Link to post
Share on other sites
1 hour ago, _Winters_ said:

but with RscXListBox I always get -1 (no selection) returned when I use lbCurSel

Should work ok, nothing is jumping out at me from what you have shown.

Heres a quick example to show it works, just run from the debugConsole..

h = [] spawn {
	disableSerialization;
	
	_display = findDisplay 46 createDisplay "RscDisplayEmpty";
	
	_lb = _display ctrlCreate [ "RscXListbox", 2000 ];
	_lb ctrlSetPosition[ 0, 0, (( pixelGrid * pixelW ) * 20 ), (( pixelGrid * pixelH ) * 2 ) ];
	_lb ctrlCommit 0;
	{
		_nul = _lb lbAdd getText (_x >> "displayName");
	}forEach ( "isClass( _x )" configClasses( configFile >> "CfgRanks" ));
	_lb lbSetCurSel 0;
	
	_btn = _display ctrlCreate [ "RscButton", 2001 ];
	_btn ctrlSetPosition[ (( pixelGrid * pixelW ) * 5 ), (( pixelGrid * pixelH ) * 3 ), (( pixelGrid * pixelW ) * 10 ), (( pixelGrid * pixelH ) * 2 ) ];
	_btn ctrlCommit 0;
	_btn ctrlSetText "Choose";
	
	_btn ctrlAddEventHandler [ "ButtonClick", {
		params[ "_btn" ];
		
		_lb = ctrlParent _btn displayCtrl 2000;
		_choosen = lbCurSel _lb;
		
		hint format[ "You choose\nindex %1\n%2", _choosen, _lb lbText _choosen ];
	}];
	
};

 

Share this post


Link to post
Share on other sites

When looking into how to get a picture to update based on a listbox, I found something that led me to figure it out.. 

 

In case this helps anyone else.. I will leave this here..  still no idea why 

 

I added the following to my file that initializes my dialog.. 

 


HelicopterListbox ctrlSetEventHandler ["LBSelChanged", "[_this] ExecVM 'scripts\XListBoxHandler.sqf'"];

 

like this.. 

 


HelicopterListbox = _dialog_control displayCtrl 1500;

 

hl_0 = _HelicopterListbox lbAdd "MH-9 Hummingbird";
hl_1 = _HelicopterListbox lbAdd "UH-80 Ghost Hawk";
hl_2 = _HelicopterListbox lbAdd "CH-67 Huron";
hl_3 = _HelicopterListbox lbAdd "V-44 X Blackfish";
hl_4 = _HelicopterListbox lbAdd "AH-99 Blackfoot";
hl_5 = _HelicopterListbox lbAdd "Mi-290 Taru";
hl_6 = _HelicopterListbox lbAdd "PO-30 Orca";
hl_7 = _HelicopterListbox lbAdd "Mi-48 Kajman";
hl_8 = _HelicopterListbox lbAdd "WY-55 Hellcat";
hl_9 = _HelicopterListbox lbAdd "CH-49 Mohawk";

 

lbSetCurSel [1500, hl_0];

 

HelicopterListbox ctrlSetEventHandler ["LBSelChanged", "[_this] ExecVM 'scripts\XListBoxHandler.sqf'"];

 

 

Now whenever the value changes in the xlistbox it fires off the event which includes the control, and the selected index

then in my new file XListBoxHandler.sqf which handles the event I have the following.

 

In this example I only show one control, but I am using this with multiple controls by just adding new cases to the select statement.

-------------------------------------------------------------------------------------

 

_control = (_this select 0) select 0;
_index = (_this select 0) select 1;


_dialog_control = findDisplay 2018;

HelicopterListbox = _dialog_control displayCtrl 1500;


switch (_control) do
{
    case HelicopterListbox:
    {
        gHeliNum = _index;
    };

 

};

 

 

Share this post


Link to post
Share on other sites

OK well I should specify.. it didn't let me 'figure it out' so much as it is an effective workaround to whatever was causing my issue.

 

I still have no idea why it wasn't working but this works and I really needed to make those eventhandlers anyhow for the next part of what I am doing which is updating pictures in the dialog based on the users selections.

 

Thanks for the reply anyhow though I do appreciate it.

Share this post


Link to post
Share on other sites

Probably the difference between onLBSelChanged and onLBListSelChanged

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

×