Skip to content

Commit

Permalink
Update button hold callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Insality committed Oct 14, 2024
1 parent 067b650 commit a5e579d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions druid/annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,8 @@ function helper.table_to_string(t) end

-- Manual Annotations --

---@class druid.component: druid.base_component

---@class druid.rich_text.metrics
---@field width number
---@field height number
Expand Down
7 changes: 6 additions & 1 deletion druid/base/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ local function on_button_release(self)
is_double_click = is_double_click and self.on_double_click:is_exist()

if is_long_click then
on_button_long_click(self)
local is_hold_complete = (time - self.last_pressed_time) >= self.style.AUTOHOLD_TRIGGER
if is_hold_complete then
on_button_long_click(self)
else
self.on_click_outside:trigger(self:get_context(), self.params, self)
end
elseif is_double_click then
on_button_double_click(self)
else
Expand Down
2 changes: 1 addition & 1 deletion druid/editor_scripts/component.lua_template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

local component = require("druid.component")

---@class {COMPONENT_TYPE}: druid.base_component
---@class {COMPONENT_TYPE}: druid.component
---@field druid druid_instance{COMPONENT_ANNOTATIONS}
local M = component.create("{COMPONENT_TYPE}")

Expand Down
2 changes: 2 additions & 0 deletions utils/annotations_manual.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-- Manual Annotations --

---@class druid.component: druid.base_component

---@class druid.rich_text.metrics
---@field width number
---@field height number
Expand Down

0 comments on commit a5e579d

Please sign in to comment.