• MouseWheel with GUI Screen Clicker
    7 replies, posted
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.
[QUOTE=Charades;44260874]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.[/QUOTE] 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]
[QUOTE=Acecool;44261477]Use this hook to grab mouse-wheel actions: [lua]hook.Add( "CreateMove", "Example:CreateMove", function( cmd ) print( cmd:GetMouseWheel( ) ); end );[/lua][/QUOTE] Last time I checked that won't return any value other than 0 if "vgui.CursorVisible()" isn't true. Meant to say "IS" true
[QUOTE=brandonj4;44261530]Last time I checked that won't return any value other than 0 if "vgui.CursorVisible()" isn't true.[/QUOTE] 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.
[QUOTE=Acecool;44262074]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.[/QUOTE] 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..
[QUOTE=Acecool;44262212]You could possibly extend the base / work-panel: vgui.GetWorldPanel( ) -- You may be able to attach the mouse-functions to it..[/QUOTE] Works perfectly. Saved me from having to mask an unnecessary vgui panel. Thanks again.
Sorry, you need to Log In to post a reply to this thread.