(hopefully) fixed reactive decimals bug

This commit is contained in:
Robert Jelic
2025-05-09 03:29:43 +02:00
parent b0660a36bf
commit 14548d9632
2 changed files with 16 additions and 6 deletions

View File

@@ -63,7 +63,6 @@ end
--- @return boolean handled Whether the event was handled
--- @protected
function Slider:mouse_click(button, x, y)
self.basalt.LOGGER.debug("Slider:mouse_click", button, x, y)
if self:isInBounds(x, y) then
local relX, relY = self:getRelativePosition(x, y)
local pos = self.get("horizontal") and relX or relY

View File

@@ -37,6 +37,9 @@ local function parseExpression(expr, element, propName)
if protectedNames[obj] then
return obj.."."..prop
end
if tonumber(obj) then
return obj.."."..prop
end
return string.format('__getProperty("%s", "%s")', obj, prop)
end)
@@ -52,6 +55,9 @@ local function parseExpression(expr, element, propName)
return element.parent:getState(prop)
end,
__getElementState = function(objName, prop)
if tonumber(objName) then
return nil
end
local target = element:getBaseFrame():getChild(objName)
if not target then
errorManager.header = "Reactive evaluation error"
@@ -61,6 +67,9 @@ local function parseExpression(expr, element, propName)
return target:getState(prop).value
end,
__getProperty = function(objName, propName)
if tonumber(objName) then
return nil
end
if objName == "self" then
return element.get(propName)
elseif objName == "parent" then
@@ -105,11 +114,13 @@ local function validateReferences(expr, element)
return false
end
else
local target = element.parent:getChild(ref)
if not target then
errorManager.header = "Reactive evaluation error"
errorManager.error("Referenced element not found: " .. ref)
return false
if(tonumber(ref) == nil)then
local target = element.parent:getChild(ref)
if not target then
errorManager.header = "Reactive evaluation error"
errorManager.error("Referenced element not found: " .. ref)
return false
end
end
end
end