Update annotations: scroll, hover and drag

This commit is contained in:
Insality
2020-10-11 23:40:16 +03:00
parent 99a5c87560
commit 082aa454c6
5 changed files with 211 additions and 186 deletions

View File

@@ -1,12 +1,14 @@
--- Component to handle hover node interaction
-- @module druid.hover
-- @module Hover
-- @within BaseComponent
-- @alias druid.hover
--- Component events
-- @table Events
-- @tfield druid_event on_hover On hover callback (Touch pressed)
-- @tfield druid_event on_mouse_hover On mouse hover callback (Touch over without action_id)
--- On hover callback(self, state)
-- @tfield druid_event on_hover
--- On mouse hover callback(self, state)
-- @tfield druid_event on_mouse_hover
local Event = require("druid.event")
local const = require("druid.const")
@@ -17,10 +19,10 @@ local Hover = component.create("hover", { const.ON_INPUT })
--- Component init function
-- @function hover:init
-- @tparam Hover self
-- @tparam node node Gui node
-- @tparam function on_hover_callback Hover callback
function Hover:init(node, on_hover_callback)
function Hover.init(self, node, on_hover_callback)
self.node = self:get_node(node)
self._is_hovered = false
@@ -33,7 +35,7 @@ function Hover:init(node, on_hover_callback)
end
function Hover:on_input(action_id, action)
function Hover.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return false
end
@@ -66,15 +68,15 @@ function Hover:on_input(action_id, action)
end
function Hover:on_input_interrupt()
function Hover.on_input_interrupt(self)
self:set_hover(false)
end
--- Set hover state
-- @function hover:set_hover
-- @tparam Hover self
-- @tparam bool state The hover state
function Hover:set_hover(state)
function Hover.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state)
@@ -82,9 +84,9 @@ function Hover:set_hover(state)
end
--- Set mouse hover state
-- @function hover:set_mouse_hover
-- @tparam Hover self
-- @tparam bool state The mouse hover state
function Hover:set_mouse_hover(state)
function Hover.set_mouse_hover(self, state)
if self._is_mouse_hovered ~= state then
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state)
@@ -94,9 +96,9 @@ end
--- Strict hover click area. Useful for
-- no click events outside stencil node
-- @function hover:set_click_zone
-- @tparam Hover self
-- @tparam node zone Gui node
function Hover:set_click_zone(zone)
function Hover.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
end
@@ -104,9 +106,9 @@ end
--- Set enable state of hover component.
-- If hover is not enabled, it will not generate
-- any hover events
-- @function hover:set_enabled
-- @tparam Hover self
-- @tparam bool state The hover enabled state
function Hover:set_enabled(state)
function Hover.set_enabled(self, state)
self._is_enabled = state
if not state then
@@ -121,9 +123,9 @@ end
--- Return current hover enabled state
-- @function hover:is_enabled
-- @tparam Hover self
-- @treturn bool The hover enabled state
function Hover:is_enabled()
function Hover.is_enabled(self)
return self._is_enabled
end