Override unusable methods in Text element

This commit is contained in:
Gabriel Tofvesson 2024-10-01 14:55:09 +00:00
parent 692d1a82b9
commit 4e171aabed

View File

@ -1,9 +1,41 @@
local Element = require("element")
local Text = Element:new{ text = "" }
function Text:new(o)
o.width = nil
o.height = nil
return Element.new(self, o)
end
function Text:setText(text)
self:setDirty()
self.text = text
end
function Text:draw()
Element.draw(self)
self.render.window.write(self.text)
end
function Text:getHeight()
return 1
end
function Text:getWidth()
return #self.text
end
function Text:setWidth()
error("Dimensions are derived from content")
end
function Text:setHeight()
error("Dimensions are derived from content")
end
function Text:resize()
error("Dimensions are derived from content")
end
return Text