mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Reimport docs
This commit is contained in:
@@ -223,6 +223,8 @@ function M:on_input(action_id, action)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
---@diagnostic disable: inject-field
|
||||
-- Source: https://github.com/britzl/defold-richtext version 5.19.0
|
||||
-- Author: Britzl
|
||||
-- Modified by: Insality
|
||||
|
@@ -27,10 +27,10 @@ end
|
||||
|
||||
|
||||
---Split string at first occurrence of token
|
||||
---@param s string The string to split
|
||||
---@param s string? The string to split
|
||||
---@param token string The token to split string on
|
||||
---@return string before The string before the token or the whole string if token doesn't exist
|
||||
---@return string after The string after the token or nil
|
||||
---@return string? before The string before the token or the whole string if token doesn't exist
|
||||
---@return string? after The string after the token or nil
|
||||
local function split(s, token)
|
||||
if not s then return nil, nil end
|
||||
local before, after = s:match("(.-)" .. token .. "(.*)")
|
||||
|
@@ -41,6 +41,7 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
---@field image druid.rich_text.word.image
|
||||
---@field br boolean
|
||||
---@field nobr boolean
|
||||
---@field tags table<string, boolean>
|
||||
|
||||
---@class druid.rich_text.word.image
|
||||
---@field texture string
|
||||
|
@@ -63,6 +63,7 @@ function M:add_hotkey(keys, callback_argument)
|
||||
local modificators = {}
|
||||
local key = nil
|
||||
|
||||
---@cast keys string[]
|
||||
for index = 1, #keys do
|
||||
local key_hash = hash(keys[index])
|
||||
if #keys > 1 and helper.contains(self.style.MODIFICATORS, key_hash) then
|
||||
@@ -84,8 +85,9 @@ function M:add_hotkey(keys, callback_argument)
|
||||
})
|
||||
|
||||
-- Current hotkey status
|
||||
for index = 1, #self.style.MODIFICATORS do
|
||||
local modificator = hash(self.style.MODIFICATORS[index])
|
||||
local mods = self.style.MODIFICATORS ---@type string[]
|
||||
for index = 1, #mods do
|
||||
local modificator = hash(mods[index])
|
||||
self._modificators[modificator] = self._modificators[modificator] or false
|
||||
end
|
||||
|
||||
|
@@ -23,9 +23,9 @@ local utf8 = utf8 or utf8_lua
|
||||
---@field on_input_wrong event fun(self: druid.input) The event triggered when the input field is wrong
|
||||
---@field on_select_cursor_change event fun(self: druid.input, cursor_index: number, start_index: number, end_index: number) The event triggered when the cursor index is changed
|
||||
---@field style druid.input.style The style of the input component
|
||||
---@field text druid.text The text component
|
||||
local M = component.create("input")
|
||||
|
||||
---@private
|
||||
M.ALLOWED_ACTIONS = {
|
||||
[const.ACTION_TOUCH] = true,
|
||||
[const.ACTION_TEXT] = true,
|
||||
@@ -61,7 +61,7 @@ end
|
||||
|
||||
---@param click_node node Node to enabled input component
|
||||
---@param text_node node|druid.text Text node what will be changed on user input. You can pass text component instead of text node name Text
|
||||
---@param keyboard_type number|nil Gui keyboard type for input field
|
||||
---@param keyboard_type constant|nil Gui keyboard type for input field
|
||||
function M:init(click_node, text_node, keyboard_type)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
@@ -269,7 +269,7 @@ end
|
||||
|
||||
|
||||
---Set text for input field
|
||||
---@param input_text string The string to apply for input field
|
||||
---@param input_text string? The string to apply for input field, if nil - will be set to empty string
|
||||
function M:set_text(input_text)
|
||||
input_text = tostring(input_text or "")
|
||||
|
||||
@@ -370,7 +370,7 @@ end
|
||||
|
||||
|
||||
---Set maximum length for input field.
|
||||
-- Pass nil to make input field unliminted (by default)
|
||||
---Pass nil to make input field unliminted (by default)
|
||||
---@param max_length number Maximum length for input text field
|
||||
---@return druid.input self Current input instance
|
||||
function M:set_max_length(max_length)
|
||||
@@ -380,9 +380,11 @@ end
|
||||
|
||||
|
||||
---Set allowed charaters for input field.
|
||||
-- See: https://defold.com/ref/stable/string/
|
||||
-- ex: [%a%d] for alpha and numeric
|
||||
---@param characters string Regulax exp. for validate user input
|
||||
---See: https://defold.com/ref/stable/string/
|
||||
---ex: [%a%d] for alpha and numeric
|
||||
---ex: [abcdef] to allow only these characters
|
||||
---ex: [^%s] to allow only non-space characters
|
||||
---@param characters string Regular expression for validate user input
|
||||
---@return druid.input self Current input instance
|
||||
function M:set_allowed_characters(characters)
|
||||
self.allowed_characters = characters
|
||||
@@ -481,6 +483,8 @@ function M:move_selection(delta, is_add_to_selection, is_move_to_end)
|
||||
end
|
||||
|
||||
self:select_cursor(cursor_index, start_index, end_index)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
@@ -49,6 +49,7 @@
|
||||
---@field screen_dy number The change in screen space y value of a pointer device, if present.
|
||||
---@field gamepad number The index of the gamepad device that provided the input.
|
||||
---@field touch touch[] List of touch input, one element per finger, if present. See table below about touch input
|
||||
---@field text string The text input.
|
||||
|
||||
---@class touch
|
||||
---@field id number A number identifying the touch input during its duration.
|
||||
|
@@ -558,7 +558,7 @@ end
|
||||
|
||||
local text = require("druid.base.text")
|
||||
---Create Text component
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@param node string|node|druid.text The node_id or gui.get_node(node_id)
|
||||
---@param value string|nil Initial text. Default value is node text from GUI scene.
|
||||
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
---@return druid.text text The new text component
|
||||
|
Reference in New Issue
Block a user