From 3dcdcfd3831b3c5fd659529846c267fe50c3d3d6 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:49:21 +0200 Subject: [PATCH] Input cursor fix Fixed cursor for input objects when changing the value via :setValue() --- Basalt/objects/Input.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Basalt/objects/Input.lua b/Basalt/objects/Input.lua index 06c68f6..8e23ce7 100644 --- a/Basalt/objects/Input.lua +++ b/Basalt/objects/Input.lua @@ -57,9 +57,9 @@ return function(name) setValue = function(self, val) base.setValue(self, tostring(val)) if not (internalValueChange) then + textX = tostring(val):len() + 1 + wIndex = math.max(1, textX-self:getWidth()+1) if(self:isFocused())then - textX = tostring(val):len() + 1 - wIndex = math.max(1, textX-self:getWidth()+1) local obx, oby = self:getAnchorPosition() self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self:getHeight()/2), self.fgColor) end