mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
fix ui elements related things
This commit is contained in:
parent
3429435ff5
commit
84b2aef81f
2 changed files with 15 additions and 9 deletions
|
|
@ -77,15 +77,18 @@ function Element.new(docname, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- the engine automatically creates an instance for every ui document (layout)
|
-- the engine automatically creates an instance for every ui document (layout)
|
||||||
local Document = {}
|
local Document = {
|
||||||
function Document.new(docname)
|
__index=function(self, k)
|
||||||
return setmetatable({name=docname}, {
|
if type(k) ~= "string" then
|
||||||
__index=function(self, k)
|
error("element id is not a string")
|
||||||
local elem = Element.new(self.name, k)
|
|
||||||
rawset(self, k, elem)
|
|
||||||
return elem
|
|
||||||
end
|
end
|
||||||
})
|
local elem = Element.new(self.name, k)
|
||||||
|
rawset(self, k, elem)
|
||||||
|
return elem
|
||||||
|
end
|
||||||
|
}
|
||||||
|
function Document.new(docname)
|
||||||
|
return setmetatable({name=docname}, Document)
|
||||||
end
|
end
|
||||||
|
|
||||||
local RadioGroup = {}
|
local RadioGroup = {}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ function test.click(node, options)
|
||||||
end
|
end
|
||||||
if not node.exists then
|
if not node.exists then
|
||||||
error(string.format("timeout %s ms exceeded: element %s does not exists",
|
error(string.format("timeout %s ms exceeded: element %s does not exists",
|
||||||
math.floor(timeout), string.escape(node.id)))
|
math.floor(timeout), string.escape(rawget(node, 'name'))))
|
||||||
end
|
end
|
||||||
|
|
||||||
local center_x, center_y = get_node_center(node)
|
local center_x, center_y = get_node_center(node)
|
||||||
|
|
@ -82,6 +82,9 @@ end
|
||||||
|
|
||||||
-- TODO: replace with resolving in C++ side
|
-- TODO: replace with resolving in C++ side
|
||||||
function test.find_by_attr(node, attr, value)
|
function test.find_by_attr(node, attr, value)
|
||||||
|
if getmetatable(node) == Document then
|
||||||
|
return test.find_by_attr(node.root, attr, value)
|
||||||
|
end
|
||||||
if node[attr] == value then
|
if node[attr] == value then
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue