Jump to content
Sign in to follow this  
BEAKSBY

Dialog ListBox and Mouse Scroll Wheel

Recommended Posts

HI All,

Does anyone know or have ever tried incorporating into a dialog script a way to select items from a ListBox using the mouse wheel instead of the mouse cursor?

This would be helpful and faster for the game I'm creating, where the player can access the list and quickly select the weapon or vehicle to purchase from the listbox.

Thanks

Share this post


Link to post
Share on other sites

If I have understood you correctly then:

Work with User Interface Event Handler:

"onMouseZChanged"

And the Commands (I hope that I have not forgotten anything)

lbCurSel

&

lbSetCurSel

If you have no clue, then i can give you an example.

Edit:

Okay i had time and made a fast example:

Open your .hpp file and add this to the ListBox-Control:

onMouseZChanged = "_this execVM 'zm.sqf'";

it should look like this:

1a1d4d77b3.png

Then create a "zm.sqf" in the root folder of your mission file, and put this in it:

////-by Lachesis580-\\\\

_zwheel = _this select 1;
_curindex = lbCurSel 5923;

if (_zwheel < 0) Then {
lbSetCurSel [5923,(_curindex +1)];
} else {
lbSetCurSel [5923,(_curindex -1)];
};

Don't forget to change the "idc".

Edited by Legion1337

Share this post


Link to post
Share on other sites

That worked!

I just changed the idc to match mine.

...and to select it by pressing the middle mouse button I can use onMouseButtonDown?

Is it better to run this as an sqf or function?

---------- Post added at 22:16 ---------- Previous post was at 21:01 ----------

I've tried this in the init:

onMouseButtonDown = "_this execVM 'bm.sqf'";

Then this for the bm.sqf:

_bwheel = _this select 1;
_curindex = lbCurSel 15001;

if (_bwheel == 1) Then {
lbSetCurSel [15001,(_curindex)], ";
};
"[15001] call FUS_fnc_LBDblClick";

and this is in the FUS_fnc_LBDblClick:

FUS_fnc_LBDblClick = {// >> Function Start
   _listBox = _this select 0;
_selection = lbCurSel _listBox;
_text = lbText [_listBox, _selection];

switch (_selection) do {
    case 0: {if (money >= 400) then {[400, "B_Heli_Transport_01_F"] call FUS_fnc_addItem;} else {hint "You don't have enough money.";};};
	case 1: {if (money >= 500) then {[500, "B_MBT_01_TUSK_F"] call FUS_fnc_addItem;} else {hint "You don't have enough money.";};};
	case 2: {if (money >= 1000) then {[1000, "B_MRAP_01_F"] call FUS_fnc_addItem;} else {hint "You don't have enough money.";};};
};
};// << Function End

Share this post


Link to post
Share on other sites

I do have middle mouse button working but I'm not convinced it's the correct way.

I'm basically adding a normal mouse button event handler to the scroll and then calling the spawn from there.

called with

class Fusion_ListBox: rscListbox
{
idc = 15001;
x = 0.43 * safezoneW + safezoneX;
y = 0.3825 * safezoneH + safezoneY;
w = 0.125 * safezoneW;
h = 0.185 * safezoneH;
        onMouseZChanged = "[_this,15001] call FUS_fnc_zwheel";
};

code added to UIFunctions list

FUS_fnc_zwheel = {
////-by Lachesis580-\\\\
hint str (_this select 0);
_idc =  (_this select 1);
_zwheel = (_this select 0) select 1 ;
_curindex = lbCurSel _idc;
rem=false;
_mouseB  = (findDisplay 46) displayAddEventHandler ["MouseButtonDown", "if (_this select 1 == 2) then {player sidechat str (_this select 1);[15001] call FUS_fnc_LBDblClick;rem=true};"];
if (rem) then { (finddisplay 46) displayremoveeventhandler ['MouseButtonDown',_mouseB];rem=false}; 
if (_zwheel < 0) Then {
lbSetCurSel [15001,(_curindex +1)];
} else {
lbSetCurSel [15001,(_curindex -1)];
};
};// << Function End

Share this post


Link to post
Share on other sites

Yeah I noticed it seems to stutter and affect the cost of abnormally.

I've downloaded this example and will try to incorportate the images associated with the vehicles in the list box similar to what is done here with the weapon and uniform dialog:

ARMA 3 Alpha GUI Test Weapon Outfit:

http://www.filefactory.com/file/51rmi34pnhgf/n/Z5_GUI_Stratis_7z

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  

×