mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
Add hotkey example
This commit is contained in:
@@ -86,11 +86,11 @@ M.REVERSE_PIVOTS = {
|
||||
|
||||
M.LAYOUT_MODE = {
|
||||
STRETCH_X = "stretch_x",
|
||||
STRETCH_Y = "stretch_y",
|
||||
STRETCH_Y = "stretch_y",
|
||||
ZOOM_MIN = "zoom_min",
|
||||
ZOOM_MAX = "zoom_max",
|
||||
FIT = gui.ADJUST_FIT,
|
||||
STRETCH = gui.ADJUST_STRETCH,
|
||||
FIT = gui.ADJUST_FIT,
|
||||
STRETCH = gui.ADJUST_STRETCH,
|
||||
}
|
||||
|
||||
|
||||
|
@@ -101,7 +101,7 @@ end
|
||||
|
||||
function Hotkey.on_input(self, action_id, action)
|
||||
if not action_id then
|
||||
return
|
||||
return false
|
||||
end
|
||||
|
||||
if self._modificators[action_id] ~= nil then
|
||||
@@ -136,12 +136,16 @@ function Hotkey.on_input(self, action_id, action)
|
||||
hotkey.is_processing = false
|
||||
if hotkey.callback_argument then
|
||||
self._callback(self:get_context(), hotkey.callback_argument)
|
||||
return true
|
||||
else
|
||||
self._callback(self:get_context())
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
@@ -148,7 +148,7 @@ M["text"] = {
|
||||
|
||||
|
||||
M["hotkey"] = {
|
||||
MODIFICATORS = {}, -- Add key ids to mark it as modificator keys
|
||||
MODIFICATORS = { "key_lshift", "key_rshift", "key_lctrl", "key_rctrl", "key_lalt", "key_ralt", "key_lsuper", "key_rsuper" }, -- Add key ids to mark it as modificator keys
|
||||
}
|
||||
|
||||
|
||||
|
@@ -31,6 +31,7 @@
|
||||
-- @see DataList
|
||||
-- @see Hover
|
||||
-- @see Layout
|
||||
-- @see Hotkey
|
||||
|
||||
local helper = require("druid.helper")
|
||||
local class = require("druid.system.middleclass")
|
||||
@@ -58,7 +59,6 @@ local radio_group = require("druid.extended.radio_group")
|
||||
local slider = require("druid.extended.slider")
|
||||
local timer = require("druid.extended.timer")
|
||||
local data_list = require("druid.extended.data_list")
|
||||
local layout = require("druid.extended.layout")
|
||||
|
||||
|
||||
local DruidInstance = class("druid.druid_instance")
|
||||
@@ -750,4 +750,15 @@ function DruidInstance.new_layout(self, node, mode)
|
||||
end
|
||||
|
||||
|
||||
--- Create hotkey component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|string[] string Keys for trigger action. Should contains one action key and any amount of modificator keys
|
||||
-- @tparam function callback Button callback
|
||||
-- @tparam[opt] value params Button callback params
|
||||
-- @treturn Layout layout component
|
||||
function DruidInstance.new_hotkey(self, keys_array, callback, params)
|
||||
return helper.extended_component("hotkey")
|
||||
end
|
||||
|
||||
|
||||
return DruidInstance
|
||||
|
Reference in New Issue
Block a user