From 2bb4b8e25d4f47085ebd39e4c4480ec2ad533d6f Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Tue, 17 Oct 2023 09:45:19 -0400 Subject: [PATCH] OnWheelMoved supported on a gui object --- init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a8fe4a2..a6902a0 100644 --- a/init.lua +++ b/init.lua @@ -83,7 +83,7 @@ local function Hook(funcname, func) end -- This will run the hooks after everything has loaded -updater:newTask(function() +updater:newLoop(function(loop) Hook("quit", gui.Events.OnQuit.Fire) Hook("directorydropped", gui.Events.OnDirectoryDropped.Fire) Hook("displayrotated", gui.Events.OnDisplayRotated.Fire) @@ -103,6 +103,7 @@ updater:newTask(function() Hook("touchmoved", gui.Events.OnTouchMoved.Fire) Hook("touchpressed", gui.Events.OnTouchPressed.Fire) Hook("touchreleased", gui.Events.OnTouchReleased.Fire) + loop:Destroy() end) -- Hotkeys @@ -470,6 +471,14 @@ function gui:newBase(typ, x, y, w, h, sx, sy, sw, sh, virtual) return true end + local function defaultCheck(...) + if not c:isActive() then return end + local x, y = love.mouse.getPosition() + if c:canPress(x, y) then + return c, ... + end + end + setmetatable(c, gui) c.__variables = {clip = {false, 0, 0, 0, 0}} c.active = true @@ -496,6 +505,7 @@ function gui:newBase(typ, x, y, w, h, sx, sy, sw, sh, virtual) c.OnExit = multi:newConnection() c.OnMoved = testHierarchy .. multi:newConnection() + c.OnWheelMoved = defaultCheck / gui.Events.OnWheelMoved local dragging = false local entered = false