Merge branch 'develop' into 102-input-priority

This commit is contained in:
Insality 2021-04-01 21:00:13 +03:00
commit 58163caf25
7 changed files with 34 additions and 12 deletions

View File

@ -138,3 +138,6 @@ Desc
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
- Add EmmyLua annotations. See how to use it FAQ
- Lang text now can be initialized without default locale id
- **#116** You can pass Text component in Input component instead of text node
- **#124** Add _set_click_zone_ functon to Scroll component (just link to Drag:set_click_zone inside scroll component)

View File

@ -263,9 +263,9 @@ end
--- Strict drag click area. Useful for
-- restrict events outside stencil node
-- @tparam Drag self
-- @tparam node zone Gui node
function Drag.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
-- @tparam node node Gui node
function Drag.set_click_zone(self, node)
self.click_zone = self:get_node(node)
end

View File

@ -379,6 +379,15 @@ function Scroll.bind_grid(self, grid)
end
--- Strict drag scroll area. Useful for
-- restrict events outside stencil node
-- @tparam Drag self
-- @tparam node node Gui node
function Scroll.set_click_zone(self, node)
self.drag:set_click_zone(node)
end
function Scroll._on_scroll_drag(self, dx, dy)
local t = self.target_position
local b = self.available_pos

View File

@ -55,6 +55,10 @@ M.PIVOTS = {
}
M.SYS_INFO = sys.get_sys_info()
M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name
M.OS = {
ANDROID = "Android",
IOS = "iPhone OS",

View File

@ -108,11 +108,16 @@ end
-- @tparam node click_node Button node to enabled input component
-- @tparam node text_node Text node what will be changed on user input
-- @tparam node|druid.text text_node Text node what will be changed on user input. You can pass text component instead of text node name
-- @tparam[opt] number keyboard_type Gui keyboard type for input field
function Input.init(self, click_node, text_node, keyboard_type)
self.druid = self:get_druid(self)
self.text = self.druid:new_text(text_node)
if type(text_node) == const.TABLE then
self.text = text_node
else
self.text = self.druid:new_text(text_node)
end
self.is_selected = false
self.value = self.text.last_value

View File

@ -21,7 +21,7 @@ local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE })
--- Component init function
-- @tparam LangText self
-- @tparam node node The text node
-- @tparam string locale_id Default locale id
-- @tparam string locale_id Default locale id, optional
-- @tparam bool no_adjust If true, will not correct text size
function LangText.init(self, node, locale_id, no_adjust)
self.druid = self:get_druid()
@ -30,7 +30,9 @@ function LangText.init(self, node, locale_id, no_adjust)
self.on_change = Event()
self:translate(locale_id)
if locale_id then
self:translate(locale_id)
end
return self
end
@ -59,7 +61,7 @@ end
function LangText.translate(self, locale_id, ...)
self.last_locale_args = {...}
self.last_locale = locale_id or self.last_locale
self.text:set_to(settings.get_text(self.last_locale, ...))
self.text:set_to(settings.get_text(self.last_locale, ...) or "")
end

View File

@ -5,6 +5,7 @@ local const = require("druid.const")
local M = {}
local system_name = sys.get_sys_info().system_name
--- Text node or icon node can be nil
local function get_text_width(text_node)
@ -182,16 +183,14 @@ end
--- Check if device is mobile (Android or iOS)
-- @function helper..is_mobile
function M.is_mobile()
local system_name = sys.get_sys_info().system_name
return system_name == const.OS.IOS or system_name == const.OS.ANDROID
return const.CURRENT_SYSTEM_NAME == const.OS.IOS or const.CURRENT_SYSTEM_NAME == const.OS.ANDROID
end
--- Check if device is HTML5
-- @function helper.is_web
function M.is_web()
local system_name = sys.get_sys_info().system_name
return system_name == const.OS.BROWSER
return const.CURRENT_SYSTEM_NAME == const.OS.BROWSER
end