about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-11-18 14:13:13 -0800
committerKartik K. Agaram <vc@akkartik.com>2023-11-18 14:15:07 -0800
commit48c05aa77a6a06329f4764ab511e39611262c23f (patch)
tree655b5d6334dd651aa84d28519bbdcea5274add83
parent007b965b11b681550ee2e2244a2f53e64e88697d (diff)
downloadlines.love-48c05aa77a6a06329f4764ab511e39611262c23f.tar.gz
late-bind my App.* handlers
This came up when trying to integrate my apps with the vudu debugger
(https://github.com/deltadaedalus/vudu). In general, it's a subtle part
of LÖVE's semantics that you can modify event handlers any time and your
modifications will get picked up. Now my Freewheeling Apps will follow
this norm as well.
-rw-r--r--app.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/app.lua b/app.lua
index cff3483..35350d4 100644
--- a/app.lua
+++ b/app.lua
@@ -406,6 +406,7 @@ local Keys_down = {}
 -- can't run any tests after this
 function App.disable_tests()
   -- have LÖVE delegate all handlers to App if they exist
+  -- make sure to late-bind handlers like LÖVE's defaults do
   for name in pairs(love.handlers) do
     if App[name] then
       -- love.keyboard.isDown doesn't work on Android, so emulate it using
@@ -421,7 +422,7 @@ function App.disable_tests()
                                 return App.keyreleased(key, scancode)
                               end
       else
-        love.handlers[name] = App[name]
+        love.handlers[name] = function(...) App[name](...) end
       end
     end
   end