mirror of
https://github.com/Insality/druid
synced 2025-09-28 02:22:19 +02:00
Move hover logic from button to hover component
This commit is contained in:
@@ -14,11 +14,12 @@ local M = component.create("hover", { const.ON_INPUT })
|
||||
-- @tparam table self Component instance
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam function on_hover_callback Hover callback
|
||||
function M.init(self, node, on_hover_callback)
|
||||
function M.init(self, node, context, on_hover_callback)
|
||||
self.style = self:get_style()
|
||||
self.node = self:get_node(node)
|
||||
|
||||
self._is_hovered = false
|
||||
self.context = context
|
||||
self.on_hover = Event()
|
||||
if on_hover_callback then
|
||||
self.on_hover:subscribe(on_hover_callback)
|
||||
@@ -29,7 +30,7 @@ end
|
||||
local function set_hover(self, state)
|
||||
if self._is_hovered ~= state then
|
||||
self._is_hovered = state
|
||||
self.on_hover:trigger(state)
|
||||
self.on_hover:trigger(self.context, state)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user