Jump to content
Sign in to follow this  
iceman77

rscCombo selections

Recommended Posts

Hi. Making a dialog here. How is it possible to realize when any given element of the listbox/combo are selected? I would like to run a script when a weapon is chosen/selected from the combo lb. IE; If I select the M4A1 from the drop down menu, then run a script. Any help is appreciated.

Dialogz = 

{
CreateDialog "NewDialog";

//WEAPON NAMES
{lbAdd[2100,_x]} forEach ["M4A1","G36C Eotech SD","MP5A5"]; //--- Primary Weapon Names

}

newdialog.jpg

Edited by Iceman77

Share this post


Link to post
Share on other sites

I've been trying to get lbSetSelection & lbselection to work somehow. I'll look into lbCurSel. Thanks.

note: I can get a hint to display, but for any selection I make. I've tried various things with the eventhandler. :mad:

FireEvents = 

{

  hint "hello";

};

Dialogz =  

{ 

       CreateDialog "NewDialog";  
       //WEAPON NAMES 
       {lbAdd[2100,_x]} forEach ["M4A1","G36C Eotech SD","MP5A5"]; //--- Primary Weapon Names 

       _display = uiNamespace getVariable "myDisplay";
       _control = _display displayCtrl 2100;
      (_control) ctrlSetEventHandler ["LBSelChanged","['ListChange', _this] call FireEvents"];

}

Share this post


Link to post
Share on other sites

When I get home, I will post a better explanation with examples

Share this post


Link to post
Share on other sites

Okay I believe it's solved. Thanks to Riouken & lbCurSel.

private ["_control","_index"];

FireEvents = 

   {

      _index = lbCurSel 2100;

      Switch (_index) Do 

           {

             Case 0:{hint "m4a1"};
             Case 1:{hint "g36"};
             Case 2:{hint "mp5a5"};

           };





   };


Dialogz = 

{


     CreateDialog "NewDialog";

     //WEAPON NAMES
     {lbAdd[2100,_x]} forEach ["M4A1","G36C Eotech SD","MP5A5"]; //--- Primary Weapon Names
     _display = uiNamespace getVariable "myDisplay";
     _control = _display displayCtrl 2100;
     (_control) ctrlSetEventHandler ["LBSelChanged","[_this select 0] call FireEvents"];



};


---------- Post added at 12:42 ---------- Previous post was at 12:40 ----------

But please do still post all of the examples Riouken! :cool:

Share this post


Link to post
Share on other sites

LbSelection and lbSetSelection are for use with multi selection listboxes, like alowing the user to select multipul rows at once. Also useful with multi column listboxes

Share this post


Link to post
Share on other sites

i was doing something like that and found it can get messy if you want to re arrange the order or something, so i started to do...

_sel = lbCurSel _listbox;
_selText = lbText [1500, _sel]; //will be a string 

Switch (_selText) Do ***
{
   Case "M4A1":{hint "m4a1"};
   Case "G36C Eotech SD":{hint "g36"};
   Case "MP5A5":{hint "mp5a5"};
};

Edited by Lifted86

Share this post


Link to post
Share on other sites

Hey,

You can tweak the Rsc definition part to attach the UI event there, the onLBSelChanged UIEH can help on that.

Here's a sample.

	class CA_GroupsList : RscCombo {
		idc = 509001;
		x = 0.01;
		y = 0.12;
		w = 0.386;

		//onLBSelChanged = "WFBE_MenuAction = 1";
		onLBSelChanged = "_this Call FNC_onSelectChange";
	};

Then you have 2 ways of doing things, either using a function like defined above and shown below.

FNC_onSelectChange = {
Private ["_listbox", "_index"];
_listbox = _this select 0;
_index = _this select 1;

hint format ["Listbox [%1] new selection is [%2]", _listbox, _index];
};

Or in your script (loop) with a global variable as commented in the Rsc example.

if (WFBE_MenuAction == 1) then {
WFBE_MenuAction = -1;
_curSel = lbCurSel _myComboBoxIDC;

hint format ["my listbox selection is now [%1]", _curSel];
};

Share this post


Link to post
Share on other sites

Thanks lifted. Though I'm not sure I understand. If you could elaborate further I'd be grateful. I'll look into lbText.

---------- Post added at 13:01 ---------- Previous post was at 13:00 ----------

Oh hey, thanks Benny! Appreciate the help.

---------- Post added at 13:10 ---------- Previous post was at 13:01 ----------

Nvm lifted. I see what you did there :ok:

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  

×