MouseWheel with GUI Screen Clicker

I am trying to get mouse wheel up and down to change a variable while the gui cursor is active. I tried utilizing the following think hook, but it didn’t work for me.

[lua]hook.Add(“Think”, “MiddleMouse”, function()
if input.IsMouseDown(MOUSE_WHEEL_DOWN) then
print( “going down” )
elseif input.IsMouseDown(MOUSE_WHEEL_UP) then
print( “going up” )
end
end)[/lua]

Thanks for the help.

Last time I tried using that function with MOUSE_WHEEL_*, it was broken.

You can either use the PlayerBindPress hook with “invprev” and “invnext” or use a vgui panel that masks the whole screen and you can use the mouse hooks on the panel to set the mouse wheel data.

Use this hook to grab mouse-wheel actions:
[lua]hook.Add( “CreateMove”, “Example:CreateMove”, function( cmd )
print( cmd:GetMouseWheel( ) );
end );[/lua]

Last time I checked that won’t return any value other than 0 if “vgui.CursorVisible()” isn’t true.

Meant to say “IS” true

I use it for my 3rd Person Free Camera – I don’t have the cursor visible and can rotate around the player fine using the X / Y values; then I use the scroll for zoom clamped from 50 to 100 ish…

It will work, try it.

It works great if gui.EnableScreenClicker() is false. The same is true for PlayerBindPress. Unfortunately gui.EnableScreenClicker() is always true in my gamemode, so neither option works. Is my last option a vgui panel? Thanks for the help Ace and Brandon.

You could possibly extend the base / work-panel: vgui.GetWorldPanel( ) – You may be able to attach the mouse-functions to it…

Works perfectly. Saved me from having to mask an unnecessary vgui panel. Thanks again.