Jump to content
Sign in to follow this  
BomosBoy

onLoad Bug?

Recommended Posts

If you call a function with onLoad in the dialog display you cant use lbSetCurSel.

I discovered this today and iam not sure if its a bug or if i missed something.

Example:

/*
	Dialog
*/
class ExampleDialog 
{
  	onLoad = "[] call SUPERTAG_fnc_SUPERFUNC";
 	//...
	class ComboBox : RscCombo
    {
      idc = 5000;
      x = 0.35 * safezoneW + safezoneX;
      y = 0.849 * safezoneH + safezoneY;
      w = 0.3 * safezoneW;
      h = 0.02 * safezoneH;

      onLBSelChanged = "[] call SUPERCOMBO_fnc_COMBO";
    };
};

/*
	Function SUPERTAG_fnc_SUPERFUNC
*/
//Adding elements to ComboBox
//...
(_display displayCtrl 5000) lbSetCurSel 0;

/*
	Function SUPERCOMBO_fnc_COMBO
*/
//...
_index = lbCurSel 5000;
//INDEX ALWAYS RETURNS -1

My Problem is that i fill the combobox with elements with the onLoad function.

Normaly if you use lbSetCurSel it automaticly fires a onLBSelChanged event.

But this time lbCurSel always returns -1. So i cant set the cursor selection with lbSetCurSel in onLoad.

Maby someone can help me.

Share this post


Link to post
Share on other sites

Where is _display defined in your script? If I were you, I would use the primary syntax for the lbSetCurSel command.

lbSetCurSel [5000, 0];

It does not require you to define the display; you only need to state the IDC of the listbox.

Share this post


Link to post
Share on other sites

_display is just a variable for the _this select 0 in the display onLoad function.

So the full "function" looks like

onLoad = "[_this select 0] call SUPERTAG_fnc_SUPERFUNC";

//SUPERTAG_fnc_SUPERFUNC
disableSerialization;
_display = _this select 0;

Share this post


Link to post
Share on other sites

FIXED:

lbCurSel (_display displayCtrl 5000); 

Works now.

_index = lbCurSel 101;

Does not work (for me). So use Example 2 in the wiki if you have the same problem.

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
Sign in to follow this  

×