mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Update Docs
This commit is contained in:
@@ -34,8 +34,21 @@ local function set_selection_width(self, selection_width)
|
||||
end
|
||||
|
||||
|
||||
---@param self druid.rich_input
|
||||
local function update_text(self)
|
||||
local left_text_part = utf8.sub(self.input:get_text(), 0, self.input.cursor_index)
|
||||
local full_text = self.input:get_text()
|
||||
local visible_text = self.input.text:get_text()
|
||||
|
||||
local is_truncated = visible_text ~= full_text
|
||||
local cursor_index = self.input.cursor_index
|
||||
if is_truncated then
|
||||
-- If text is truncated, we need to adjust the cursor index
|
||||
-- to the last visible character
|
||||
cursor_index = utf8.len(visible_text)
|
||||
|
||||
end
|
||||
|
||||
local left_text_part = utf8.sub(self.input:get_text(), 0, cursor_index)
|
||||
local selected_text_part = utf8.sub(self.input:get_text(), self.input.start_index + 1, self.input.end_index)
|
||||
|
||||
local left_part_width = self.input.text:get_text_size(left_text_part)
|
||||
@@ -44,7 +57,7 @@ local function update_text(self)
|
||||
local pivot_text = gui.get_pivot(self.input.text.node)
|
||||
local pivot_offset = helper.get_pivot_offset(pivot_text)
|
||||
|
||||
self.cursor_position.x = self.text_position.x - self.input.total_width * (0.5 + pivot_offset.x) + left_part_width
|
||||
self.cursor_position.x = self.text_position.x - self.input.text_width * (0.5 + pivot_offset.x) + left_part_width
|
||||
|
||||
gui.set_position(self.cursor, self.cursor_position)
|
||||
gui.set_scale(self.cursor, self.input.text.scale)
|
||||
|
Reference in New Issue
Block a user