Jump to content
Sign in to follow this  
eagledude4

Mouse scroll event handler?

Recommended Posts

I thought I seen it somewhere, but can't find it on the wiki. Could someone send me a page on info for a mouse scrolling event handler?

Share this post


Link to post
Share on other sites

I'm not quite sure how to use those in the way I intended. I wanted a way to null the action of the scroll wheel similar to the way Gigan's gcam script does, although Gigan didn't use the onMouseZChanged event handler.

Share this post


Link to post
Share on other sites

From the wiki.

onMouseZChanged = "_step = (sliderSpeed (_this select 0)) select 1; _dir = if (_this select 1>0) then {1} else {-1}; (_this select 0) sliderSetPosition (sliderPosition (_this select 0) + _step*_dir)";

Share this post


Link to post
Share on other sites

Also placing this will detect mouse scroll in normal scripting.

null=[] execvm "mousescroll.sqf"

save as mousescroll.sqf

 while {true} do {
(findDisplay 46) displayAddEventHandler ["MouseZchanged","hint str (_this select 1)"];
sleep 0.5;
};  

It will display a positive and negative number when wheel is scrolled.

Share this post


Link to post
Share on other sites

Thanks F2k Sel, but that's not really the behavior I'm looking for:

onKeyPress = compile preprocessFile "actions\onKeyPress.sqf";
onScrollWheel = compile preprocessFile "actions\onScrollWheel.sqf";
waituntil {!(IsNull (findDisplay 46))};
(findDisplay 46) displayAddEventHandler ["KeyDown", "_this call onKeyPress"];
(findDisplay 46) displayAddEventHandler ["MouseZchanged","_this call onScrollWheel"];

I want the behavior to be similar to the way I process the keydown event. The scroll menu should not display unless onScrollWheel returns true.

Edited by eagledude4

Share this post


Link to post
Share on other sites

Not sure I understand but I would use this when using a function to determine mousescroll up/down

onScrollWheel = {
    private ["_r"] ;
    _r = false ; 
   if ((_this select 1) < 0) then {
       // place your code here
       hint "scroll down"; 
        _r = true;
     };

      if ((_this select 1) > 0) then {
       // place your code here
       hint ""; 
        _r = true;
     };
   _r;
} ;

Down brings up a hint and up cancels it, sorry if it's no help.

Share this post


Link to post
Share on other sites

For what I'm trying to accomplish, up or down doesn't matter :P To be more clear:

onKeyPress = compile preprocessFile "actions\onKeyPress.sqf";
waituntil {!(IsNull (findDisplay 46))};
(findDisplay 46) displayAddEventHandler ["KeyDown", "_this call onKeyPress"];

the KeyDown event handler doesn't trigger when the "_this call onKeyPress" parameter is false. so I can block people from bringing up their gear under conditions in onKeyPress.sqf.

I want the same behavior for the MouseZchanged event handler.

onKeyPress.sqf:

//By OneShot.J
private["_handled"];

_handled = false;

if (isciv) then {
_vcls = nearestobjects [getpos player, ["LandVehicle", "Air", "Ship"], 5];
_vcl = _vcls select 0;
_PatrolCars = ["ilpd_beat_f101","ilpd_slick_b40_pb"];
_UCCars = ["A2L_Tahoe_Blackuc","A2L_Tahoe_Whiteuc","suburban_pd_black","bcpd_unmarked_black","bcpd_unmarked_white","bcpd_unmarked_grey","bcpd_unmarked_blue","bcpd_unmarked_sandstone","bcpd_unmarked_maroon"];
_PD = _PatrolCars + _UCCars + ["suburban_pd_k9"];
[color="#FF0000"]if (isstunned) exitwith {};
if ((vehicle player == player) and (player distance _vcl <= 5) and (locked _vcl)) exitwith {};
if ((typeOf vehicle player in _PD) and (player in crew vehicle player)) exitwith {};[/color]
};
_handled = true;

_handled;

Under these 3 highlighted conditions, the script should exit with a false return and the event should be cancelled, correct?

Edited by eagledude4

Share this post


Link to post
Share on other sites

Sorry but I don't really know what your trying to achieve, If I run the above it locks me out of the game unless I place a time on a trigger to kill me.

If I do move _handled = true; into the if (isciv) then { } code then I can get some movement until I move out of range of the vehicle. Then it locks up again.

I don't see what this has to do with blocking gear or mouseZ.

I think exitwith only moves you out of the if (isciv) then { your code} then it sees _handled = true; so it is always true.

maybe it should be like this

//By OneShot.J
private["_handled"];

_handled = false;

if (isciv) then {
_vcls = nearestobjects [getpos player, ["LandVehicle", "Air", "Ship"], 5];
_vcl = _vcls select 0;
_PatrolCars = ["ilpd_beat_f101","ilpd_slick_b40_pb"];
_UCCars = ["A2L_Tahoe_Blackuc","A2L_Tahoe_Whiteuc","suburban_pd_black","bcpd_unmarked_black","bcpd_unmarked_white","bcpd_unmarked_grey","bcpd_unmarked_blue","bcpd_unmarked_sandstone","bcpd_unmarked_maroon"];
_PD = _PatrolCars + _UCCars + ["suburban_pd_k9"];
if (isstunned) exitwith {hint "istunned"};
if ((vehicle player == player) and (player distance _vcl <= 5) and (locked _vcl)) exitwith {hint "Vehicle player"};
if ((typeOf vehicle player in _PD) and (player in crew vehicle player)) exitwith {hint "type"};
} else { _handled = true };

_handled;

I'm just guessing really.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

I thought exitwith exited out of the whole script. I'll test your version and see what happens.

Both the hint and the action menu pop up. The return booleans seem to have no effect.

Edited by eagledude4

Share this post


Link to post
Share on other sites
I thought exitwith exited out of the whole script. I'll test your version and see what happens.

Both the hint and the action menu pop up. The return booleans seem to have no effect.

What are they supposed to have an effect on and where are you trying to get the return

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  

×