mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Merge branch 'develop' into 102-input-priority
This commit is contained in:
commit
58163caf25
@ -138,3 +138,6 @@ Desc
|
|||||||
|
|
||||||
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
|
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
|
||||||
- Add EmmyLua annotations. See how to use it FAQ
|
- 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)
|
||||||
|
@ -263,9 +263,9 @@ end
|
|||||||
--- Strict drag click area. Useful for
|
--- Strict drag click area. Useful for
|
||||||
-- restrict events outside stencil node
|
-- restrict events outside stencil node
|
||||||
-- @tparam Drag self
|
-- @tparam Drag self
|
||||||
-- @tparam node zone Gui node
|
-- @tparam node node Gui node
|
||||||
function Drag.set_click_zone(self, zone)
|
function Drag.set_click_zone(self, node)
|
||||||
self.click_zone = self:get_node(zone)
|
self.click_zone = self:get_node(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,6 +379,15 @@ function Scroll.bind_grid(self, grid)
|
|||||||
end
|
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)
|
function Scroll._on_scroll_drag(self, dx, dy)
|
||||||
local t = self.target_position
|
local t = self.target_position
|
||||||
local b = self.available_pos
|
local b = self.available_pos
|
||||||
|
@ -55,6 +55,10 @@ M.PIVOTS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
M.SYS_INFO = sys.get_sys_info()
|
||||||
|
M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name
|
||||||
|
|
||||||
|
|
||||||
M.OS = {
|
M.OS = {
|
||||||
ANDROID = "Android",
|
ANDROID = "Android",
|
||||||
IOS = "iPhone OS",
|
IOS = "iPhone OS",
|
||||||
|
@ -108,11 +108,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- @tparam node click_node Button node to enabled input component
|
-- @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
|
-- @tparam[opt] number keyboard_type Gui keyboard type for input field
|
||||||
function Input.init(self, click_node, text_node, keyboard_type)
|
function Input.init(self, click_node, text_node, keyboard_type)
|
||||||
self.druid = self:get_druid(self)
|
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.is_selected = false
|
||||||
self.value = self.text.last_value
|
self.value = self.text.last_value
|
||||||
|
@ -21,7 +21,7 @@ local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE })
|
|||||||
--- Component init function
|
--- Component init function
|
||||||
-- @tparam LangText self
|
-- @tparam LangText self
|
||||||
-- @tparam node node The text node
|
-- @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
|
-- @tparam bool no_adjust If true, will not correct text size
|
||||||
function LangText.init(self, node, locale_id, no_adjust)
|
function LangText.init(self, node, locale_id, no_adjust)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
@ -30,7 +30,9 @@ function LangText.init(self, node, locale_id, no_adjust)
|
|||||||
|
|
||||||
self.on_change = Event()
|
self.on_change = Event()
|
||||||
|
|
||||||
self:translate(locale_id)
|
if locale_id then
|
||||||
|
self:translate(locale_id)
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -59,7 +61,7 @@ end
|
|||||||
function LangText.translate(self, locale_id, ...)
|
function LangText.translate(self, locale_id, ...)
|
||||||
self.last_locale_args = {...}
|
self.last_locale_args = {...}
|
||||||
self.last_locale = locale_id or self.last_locale
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ local const = require("druid.const")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
local system_name = sys.get_sys_info().system_name
|
||||||
|
|
||||||
--- Text node or icon node can be nil
|
--- Text node or icon node can be nil
|
||||||
local function get_text_width(text_node)
|
local function get_text_width(text_node)
|
||||||
@ -182,16 +183,14 @@ end
|
|||||||
--- Check if device is mobile (Android or iOS)
|
--- Check if device is mobile (Android or iOS)
|
||||||
-- @function helper..is_mobile
|
-- @function helper..is_mobile
|
||||||
function M.is_mobile()
|
function M.is_mobile()
|
||||||
local system_name = sys.get_sys_info().system_name
|
return const.CURRENT_SYSTEM_NAME == const.OS.IOS or const.CURRENT_SYSTEM_NAME == const.OS.ANDROID
|
||||||
return system_name == const.OS.IOS or system_name == const.OS.ANDROID
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if device is HTML5
|
--- Check if device is HTML5
|
||||||
-- @function helper.is_web
|
-- @function helper.is_web
|
||||||
function M.is_web()
|
function M.is_web()
|
||||||
local system_name = sys.get_sys_info().system_name
|
return const.CURRENT_SYSTEM_NAME == const.OS.BROWSER
|
||||||
return system_name == const.OS.BROWSER
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user