mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Add hotkey example
This commit is contained in:
38
example/examples/general/hotkey/hotkey.gui_script
Normal file
38
example/examples/general/hotkey/hotkey.gui_script
Normal file
@@ -0,0 +1,38 @@
|
||||
local hotkey = require("druid.extended.hotkey")
|
||||
local druid = require("druid.druid")
|
||||
|
||||
|
||||
local function on_hotkey(self)
|
||||
self.counter = self.counter + 1
|
||||
gui.set_text(gui.get_node("text_counter"), "Counter: " .. self.counter)
|
||||
end
|
||||
|
||||
|
||||
function init(self)
|
||||
druid.register("hotkey", hotkey)
|
||||
self.druid = druid.new(self)
|
||||
self.counter = 0
|
||||
|
||||
self.hotkey = self.druid:new_hotkey({ "key_lsuper", "key_g" }, on_hotkey)
|
||||
self.hotkey:add_hotkey({ "key_lctrl", "key_g"})
|
||||
end
|
||||
|
||||
|
||||
function final(self)
|
||||
self.druid:final()
|
||||
end
|
||||
|
||||
|
||||
function update(self, dt)
|
||||
self.druid:update(dt)
|
||||
end
|
||||
|
||||
|
||||
function on_message(self, message_id, message, sender)
|
||||
self.druid:on_message(message_id, message, sender)
|
||||
end
|
||||
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
return self.druid:on_input(action_id, action)
|
||||
end
|
Reference in New Issue
Block a user