Annotations update [5]

This commit is contained in:
Insality 2023-10-18 10:40:08 +03:00
parent 24bb39481d
commit 4a16a8bc07
10 changed files with 209 additions and 9 deletions

View File

@ -149,6 +149,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Hotkey</span></span>
Current instance
</ol>

View File

@ -82,11 +82,19 @@
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#get_text">get_text(self)</a></td>
<td class="summary">GSet input field text</td>
</tr>
<tr>
<td class="name" nowrap><a href="#init">init(self, template, nodes)</a></td>
<td class="summary">The <a href="../modules/RichInput.html#">RichInput</a> constructor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_allowed_characters">set_allowed_characters(self, characters)</a></td>
<td class="summary">Set allowed charaters for input field.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_placeholder">set_placeholder(self, placeholder_text)</a></td>
<td class="summary">Set placeholder text</td>
</tr>
@ -122,6 +130,33 @@
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "get_text"></a>
<strong>get_text(self)</strong>
</dt>
<dd>
GSet input field text
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">RichInput</span></span>
<a href="../modules/RichInput.html#">RichInput</a>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Current input text
</ol>
</dd>
<dt>
<a name = "init"></a>
<strong>init(self, template, nodes)</strong>
@ -150,6 +185,39 @@
</dd>
<dt>
<a name = "set_allowed_characters"></a>
<strong>set_allowed_characters(self, characters)</strong>
</dt>
<dd>
Set allowed charaters for input field.
See: https://defold.com/ref/stable/string/
ex: [%a%d] for alpha and numeric
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">RichInput</span></span>
<a href="../modules/RichInput.html#">RichInput</a>
</li>
<li><span class="parameter">characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Regulax exp. for validate user input
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">RichInput</span></span>
Current instance
</ol>
</dd>
<dt>
<a name = "set_placeholder"></a>
@ -171,6 +239,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">RichInput</span></span>
Current instance
</ol>

View File

@ -137,6 +137,10 @@
<td class="summary">Set scale</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_size">set_size(self, size)</a></td>
<td class="summary">Set text area size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_text_adjust">set_text_adjust(self, adjust_type, minimal_scale)</a></td>
<td class="summary">Set text adjust, refresh the current text visuals, if needed</td>
</tr>
@ -163,6 +167,10 @@
<td class="summary">Current text color</td>
</tr>
<tr>
<td class="name" nowrap><a href="#last_value">last_value</a></td>
<td class="summary">The last text value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Text node</td>
</tr>
@ -489,6 +497,37 @@
</dd>
<dt>
<a name = "set_size"></a>
<strong>set_size(self, size)</strong>
</dt>
<dd>
Set text area size
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
<a href="../modules/Text.html#">Text</a>
</li>
<li><span class="parameter">size</span>
<span class="types"><span class="type">vector3</span></span>
The new text area size
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
</dd>
<dt>
<a name = "set_text_adjust"></a>
@ -632,6 +671,26 @@
</dd>
<dt>
<a name = "last_value"></a>
<strong>last_value</strong>
</dt>
<dd>
The last text value
<ul>
<li><span class="parameter">last_value</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>

View File

@ -1,8 +1,5 @@
-- luacheck: ignore
---@diagnostic disable: lowercase-global
---@diagnostic disable: missing-return
---@diagnostic disable: duplicate-doc-param
---@diagnostic disable: duplicate-set-field
---@meta
---@class druid
local druid = {}
@ -565,6 +562,7 @@ local druid__hotkey = {}
---@param self druid.hotkey @{Hotkey}
---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate
---@param callback_argument any|nil The argument to pass into the callback function
---@return druid.hotkey Current instance
function druid__hotkey.add_hotkey(self, keys, callback_argument) end
--- The @{Hotkey} constructor
@ -936,15 +934,28 @@ function druid__radio_group.set_state(self, index, is_instant) end
---@field root node Root node
local druid__rich_input = {}
--- GSet input field text
---@param self druid.rich_input @{RichInput}
---@return string Current input text
function druid__rich_input.get_text(self) end
--- The @{RichInput} constructor
---@param self druid.rich_input @{RichInput}
---@param template string The template string name
---@param nodes table Nodes table from gui.clone_tree
function druid__rich_input.init(self, template, nodes) end
--- Set allowed charaters for input field.
--- See: https://defold.com/ref/stable/string/ ex: [%a%d] for alpha and numeric
---@param self druid.rich_input @{RichInput}
---@param characters string Regulax exp. for validate user input
---@return druid.rich_input Current instance
function druid__rich_input.set_allowed_characters(self, characters) end
--- Set placeholder text
---@param self druid.rich_input @{RichInput}
---@param placeholder_text string|nil The placeholder text
---@return druid.rich_input Current instance
function druid__rich_input.set_placeholder(self, placeholder_text) end
@ -1305,6 +1316,7 @@ local druid__swipe__style = {}
---@class druid.text : druid.base_component
---@field adjust_type number Current text size adjust settings
---@field color vector3 Current text color
---@field last_value string The last text value
---@field node node Text node
---@field node_id hash The node id of text node
---@field on_set_pivot druid.event On change pivot callback(self, pivot)
@ -1374,6 +1386,12 @@ function druid__text.set_pivot(self, pivot) end
---@return druid.text Current text instance
function druid__text.set_scale(self, scale) end
--- Set text area size
---@param self druid.text @{Text}
---@param size vector3 The new text area size
---@return druid.text Current text instance
function druid__text.set_size(self, size) end
--- Set text adjust, refresh the current text visuals, if needed
---@param self druid.text @{Text}
---@param adjust_type number|nil See const.TEXT_ADJUST. If pass nil - use current adjust type

View File

@ -51,7 +51,7 @@ function Blocker.on_input(self, action_id, action)
return false
end
if not self:is_enabled(self.node) then
if not self:is_enabled() then
return false
end

View File

@ -621,8 +621,8 @@ function Scroll._check_points(self)
local temp_dist = math.huge
local temp_dist_on_inert = math.huge
local index = false
local index_on_inert = false
local index = -1
local index_on_inert = -1
local pos = self.position
for i = 1, #self.points do
@ -647,7 +647,11 @@ function Scroll._check_points(self)
end
end
self:scroll_to_index(index_on_inert or index)
if index_on_inert >= 0 then
self:scroll_to_index(index_on_inert)
else
self:scroll_to_index(index)
end
end

View File

@ -53,6 +53,9 @@
--- Current text position
-- @tfield vector3 pos
--- The last text value
-- @tfield string last_value
--- Initial text node scale
-- @tfield vector3 start_scale
@ -320,6 +323,19 @@ function Text.set_to(self, set_to)
end
--- Set text area size
-- @tparam Text self @{Text}
-- @tparam vector3 size The new text area size
-- @treturn Text Current text instance
function Text.set_size(self, size)
self.start_size = size
self.text_area = vmath.vector3(size)
self.text_area.x = self.text_area.x * self.start_scale.x
self.text_area.y = self.text_area.y * self.start_scale.y
update_adjust(self)
end
--- Set color
-- @tparam Text self @{Text}
-- @tparam vector4 color Color for node

View File

@ -91,10 +91,32 @@ end
--- Set placeholder text
-- @tparam RichInput self @{RichInput}
-- @tparam string|nil placeholder_text The placeholder text
-- @treturn RichInput Current instance
function RichInput.set_placeholder(self, placeholder_text)
self.placeholder:set_to(placeholder_text)
return self
end
---GSet input field text
-- @tparam RichInput self @{RichInput}
-- @treturn string Current input text
function RichInput.get_text(self)
return self.input:get_text()
end
--- Set allowed charaters for input field.
-- See: https://defold.com/ref/stable/string/
-- ex: [%a%d] for alpha and numeric
-- @tparam RichInput self @{RichInput}
-- @tparam string characters Regulax exp. for validate user input
-- @treturn RichInput Current instance
function RichInput.set_allowed_characters(self, characters)
self.input:set_allowed_characters(characters)
return self
end
return RichInput

View File

@ -64,6 +64,7 @@ end
-- @tparam Hotkey self @{Hotkey}
-- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate
-- @tparam any|nil callback_argument The argument to pass into the callback function
-- @treturn Hotkey Current instance
function Hotkey.add_hotkey(self, keys, callback_argument)
keys = keys or {}
if type(keys) == "string" then

View File

@ -302,7 +302,7 @@ function Input.select(self)
self.style.on_select(self, self.button.node)
else
if self.style.IS_UNSELECT_ON_RESELECT then
self:unselect(self)
self:unselect()
end
end
end