feat: add keypressed customization

This commit is contained in:
Kazhnuz 2021-08-31 10:56:56 +02:00
parent 36b4d16939
commit 70f1fe21e9

View file

@ -18,6 +18,10 @@ function GuiElement:new(name, x, y, w, h)
self:register() self:register()
end end
function GuiElement:setKeyPressAction(func)
self.func = func
end
function GuiElement:getGui() function GuiElement:getGui()
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
return scene.gui return scene.gui
@ -127,7 +131,9 @@ end
-- Handle key press -- Handle key press
function GuiElement:keypressed(key) function GuiElement:keypressed(key)
-- Cette fonction ne contient rien par défaut if (self.func ~= nil) then
self.func(key)
end
end end
-- MOUSE FUNCTIONS -- MOUSE FUNCTIONS