Fixed EditLine text not visible if using dynamic width/height, fixed cursor in wrong position when at start/end

This commit is contained in:
2020-06-07 13:18:03 -05:00
parent c3b227d6e7
commit a05ee57f6f

View File

@@ -22,7 +22,7 @@ module CyberarmEngine
end
def render
Gosu.clip_to(@text.x, @text.y, @style.width, @text.height) do
Gosu.clip_to(@text.x, @text.y, @width, @height) do
Gosu.translate(-@offset_x, 0) do
draw_selection
draw_caret if @focus && @show_caret
@@ -110,9 +110,9 @@ module CyberarmEngine
def text_input_position_for(method)
if @type == :password
@text.x + @text.width(default(:password_character) * @text_input.text[0..@text_input.send(method)].length)
@text.x + @text.width(default(:password_character) * @text_input.text[0...@text_input.send(method)].length)
else
@text.x + @text.width(@text_input.text[0..@text_input.send(method)])
@text.x + @text.width(@text_input.text[0...@text_input.send(method)])
end
end