mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Refactor text setting methods and remove ldoc files
This commit is contained in:
@@ -485,7 +485,11 @@ end
|
||||
---@param key hash|string The action_id of the input key. Example: "key_space"
|
||||
---@return druid.button self
|
||||
function M:set_key_trigger(key)
|
||||
self.key_trigger = hash(key)
|
||||
if type(key) == "string" then
|
||||
self.key_trigger = hash(key)
|
||||
else
|
||||
self.key_trigger = key
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -498,22 +502,24 @@ function M:get_key_trigger()
|
||||
end
|
||||
|
||||
|
||||
--- Set function for additional check for button click availability
|
||||
---Set function for additional check for button click availability
|
||||
---@param check_function function|nil Should return true or false. If true - button can be pressed.
|
||||
---@param failure_callback function|nil Function will be called on button click, if check function return false
|
||||
---@return druid.button self
|
||||
function M:set_check_function(check_function, failure_callback)
|
||||
self._check_function = check_function
|
||||
self._failure_callback = failure_callback
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set Button mode to work inside user HTML5 interaction event.
|
||||
--
|
||||
-- It's required to make protected things like copy & paste text, show mobile keyboard, etc
|
||||
-- The HTML5 button's doesn't call any events except on_click event.
|
||||
--
|
||||
-- If the game is not HTML, html mode will be not enabled
|
||||
---Set Button mode to work inside user HTML5 interaction event.
|
||||
---
|
||||
---It's required to make protected things like copy & paste text, show mobile keyboard, etc
|
||||
---The HTML5 button's doesn't call any events except on_click event.
|
||||
---
|
||||
---If the game is not HTML, html mode will be not enabled
|
||||
---@param is_web_mode boolean|nil If true - button will be called inside html5 callback
|
||||
---@return druid.button self
|
||||
function M:set_web_user_interaction(is_web_mode)
|
||||
|
@@ -206,9 +206,10 @@ end
|
||||
-- @tfield number|nil DRAG_DEADZONE Distance in pixels to start dragging. Default: 10
|
||||
-- @tfield boolean|nil NO_USE_SCREEN_KOEF If screen aspect ratio affects on drag values. Default: false
|
||||
function M:on_style_change(style)
|
||||
self.style = {}
|
||||
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
|
||||
self.style.NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false
|
||||
self.style = {
|
||||
DRAG_DEADZONE = style.DRAG_DEADZONE or 10,
|
||||
NO_USE_SCREEN_KOEF = style.NO_USE_SCREEN_KOEF or false,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
@@ -27,9 +27,9 @@ local component = require("druid.component")
|
||||
---@field on_mouse_hover event
|
||||
---@field style table
|
||||
---@field click_zone node
|
||||
---@field private _is_hovered boolean
|
||||
---@field private _is_mouse_hovered boolean
|
||||
---@field private _is_enabled boolean
|
||||
---@field private _is_hovered boolean|nil
|
||||
---@field private _is_mouse_hovered boolean|nil
|
||||
---@field private _is_enabled boolean|nil
|
||||
---@field private _is_mobile boolean
|
||||
local M = component.create("hover")
|
||||
|
||||
@@ -163,6 +163,11 @@ end
|
||||
-- no click events outside stencil node
|
||||
---@param zone node|string|nil Gui node
|
||||
function M:set_click_zone(zone)
|
||||
if not zone then
|
||||
self.click_zone = nil
|
||||
return
|
||||
end
|
||||
|
||||
self.click_zone = self:get_node(zone)
|
||||
end
|
||||
|
||||
|
@@ -515,22 +515,22 @@ function M:set_pivot(pivot)
|
||||
end
|
||||
|
||||
|
||||
--- Return true, if text with line break
|
||||
---Return true, if text with line break
|
||||
---@return boolean Is text node with line break
|
||||
function M:is_multiline()
|
||||
return gui.get_line_break(self.node)
|
||||
end
|
||||
|
||||
|
||||
--- Set text adjust, refresh the current text visuals, if needed
|
||||
---Set text adjust, refresh the current text visuals, if needed
|
||||
---Values are: "downscale", "trim", "no_adjust", "downscale_limited",
|
||||
---"scroll", "scale_then_scroll", "trim_left", "scale_then_trim", "scale_then_trim_left"
|
||||
---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type
|
||||
---@param minimal_scale number|nil If pass nil - not use minimal scale
|
||||
---@param minimal_scale number|nil To remove minimal scale, use `text:set_minimal_scale(nil)`, if pass nil - not change minimal scale
|
||||
---@return druid.text self Current text instance
|
||||
function M:set_text_adjust(adjust_type, minimal_scale)
|
||||
self.adjust_type = adjust_type
|
||||
self._minimal_scale = minimal_scale
|
||||
self._minimal_scale = minimal_scale or self._minimal_scale
|
||||
self:set_text(self.last_value)
|
||||
|
||||
return self
|
||||
|
Reference in New Issue
Block a user