From 70f1fe21e91a7ac3fe8dce59f4b1a3253877bdd3 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 31 Aug 2021 10:56:56 +0200 Subject: [PATCH] feat: add keypressed customization --- sonic-radiance.love/birb/modules/gui/elements/parent.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sonic-radiance.love/birb/modules/gui/elements/parent.lua b/sonic-radiance.love/birb/modules/gui/elements/parent.lua index 1d44c39..10af95c 100644 --- a/sonic-radiance.love/birb/modules/gui/elements/parent.lua +++ b/sonic-radiance.love/birb/modules/gui/elements/parent.lua @@ -18,6 +18,10 @@ function GuiElement:new(name, x, y, w, h) self:register() end +function GuiElement:setKeyPressAction(func) + self.func = func +end + function GuiElement:getGui() local scene = core.scenemanager.nextScene or core.scenemanager.currentScene return scene.gui @@ -127,7 +131,9 @@ end -- Handle key press function GuiElement:keypressed(key) - -- Cette fonction ne contient rien par défaut + if (self.func ~= nil) then + self.func(key) + end end -- MOUSE FUNCTIONS