Skip to content

Commit 4cb16de

Browse files
committed
Merge branch 'master' into develop
2 parents 8d35dc0 + afdcbe1 commit 4cb16de

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

.defignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/dist
2-
/.deployer_cache
2+
/.deployer_cache

druid/extended/input.lua

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function M:on_input(action_id, action)
182182
if self.max_length then
183183
self.marked_value = utf8.sub(self.marked_value, 1, self.max_length)
184184
end
185-
is_marked_text_changed = true
185+
is_marked_text_changed = self.marked_value ~= ""
186186
end
187187

188188
if action_id == const.ACTION_BACKSPACE and (action.pressed or action.repeated) then
@@ -222,7 +222,7 @@ function M:on_input(action_id, action)
222222
end
223223

224224
if input_text or is_marked_text_changed then
225-
self:set_text(input_text)
225+
self:set_text(input_text or self.value)
226226

227227
if cursor_shift_indexes then
228228
self:select_cursor(self.cursor_index + cursor_shift_indexes)
@@ -247,12 +247,6 @@ function M:on_focus_lost()
247247
end
248248

249249

250-
---@private
251-
function M:on_input_interrupt()
252-
--self:unselect()
253-
end
254-
255-
256250
function M:get_text_selected()
257251
if self.start_index == self.end_index then
258252
return self.value

example/druid.gui_script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ local function setup_components(self)
175175
return
176176
end
177177

178-
local url_prefix = "https://github.com/Insality/druid/blob/develop/"
178+
local url_prefix = "https://github.com/Insality/druid/blob/master/"
179179
sys.open_url(url_prefix .. code_url, { target = "_blank" })
180180
end)
181181
end

example/examples/basic/input/basic_input.lua

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,33 @@
22
---@field input druid.input
33
local M = {}
44

5-
function M:init()
5+
6+
local COLOR_SELECTED = vmath.vector3(1, 1, 1)
7+
local COLOR_UNSELECTED = vmath.vector3(184/255, 189/255, 194/255)
8+
9+
---@param template string
10+
---@param nodes table<hash, node>
11+
function M:init(template, nodes)
12+
self.druid = self:get_druid(template, nodes)
13+
614
self.input = self.druid:new_input("input/root", "input/text")
15+
self.input.on_input_select:subscribe(function()
16+
gui.set_color(self.input.text.node, COLOR_SELECTED)
17+
end)
18+
self.input.on_input_unselect:subscribe(function(_, text)
19+
print("User Enters Text: " .. text)
20+
gui.set_color(self.input.text.node, COLOR_UNSELECTED)
21+
end)
722

8-
self.input_2 = self.druid:new_input("input_2/root", "input_2/text") --[[@as druid.input]]
23+
self.input_2 = self.druid:new_input("input_2/root", "input_2/text")
24+
self.input_2:set_text("")
25+
self.input_2.on_input_select:subscribe(function()
26+
gui.set_color(self.input_2.text.node, COLOR_SELECTED)
27+
end)
28+
self.input_2.on_input_unselect:subscribe(function(_, text)
29+
print("User Enters Text: " .. text)
30+
gui.set_color(self.input_2.text.node, COLOR_UNSELECTED)
31+
end)
932

1033
-- you can set custom style for input and their components
1134
-- Check in the example, how long tap on bottom input will erase text

0 commit comments

Comments
 (0)