diff --git a/docs_md/changelog.md b/docs_md/changelog.md index 8f35d96..4c73051 100644 --- a/docs_md/changelog.md +++ b/docs_md/changelog.md @@ -138,4 +138,6 @@ Desc - Input component: rename field _selected_ to _is_selected_ (according to the docs) - Add EmmyLua annotations. See how to use it FAQ -- **#116** You can pass Text component in Input component instead of text node \ No newline at end of file +- 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) diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 8632929..9263e29 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -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 diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 4c532ca..c7681ae 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -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 diff --git a/druid/const.lua b/druid/const.lua index c50cf8e..9f1fc0d 100644 --- a/druid/const.lua +++ b/druid/const.lua @@ -51,6 +51,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", diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index b62aa6e..64479d1 100644 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -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 diff --git a/druid/helper.lua b/druid/helper.lua index 590f5ae..cc83abc 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -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