Update component docs

This commit is contained in:
Insality
2020-03-21 21:37:32 +03:00
parent b33efd692f
commit ca78b10794
20 changed files with 603 additions and 334 deletions

View File

@@ -1,5 +1,9 @@
--- Component to handle hover node interaction
-- @module druid.input
-- @module druid.hover
--- Component events
-- @table Events
-- @tfield druid_event on_hover On hover callback
local Event = require("druid.event")
local const = require("druid.const")
@@ -11,7 +15,6 @@ local M = component.create("hover", { const.ON_INPUT })
--- Component init function
-- @function hover:init
-- @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)
@@ -24,14 +27,6 @@ function M.init(self, node, on_hover_callback)
end
function M.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state)
end
end
function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then
return
@@ -64,10 +59,20 @@ function M.on_input_interrupt(self)
end
--- Set hover state
-- @function hover:set_hover
-- @tparam bool state The hover state
function M.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state)
end
end
--- Strict button click area. Useful for
-- no click events outside stencil node
-- @function button:set_click_zone
-- @tparam table self Component instance
-- @tparam node zone Gui node
function M.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)