Override unusable methods in Text element
This commit is contained in:
parent
692d1a82b9
commit
4e171aabed
32
gfx/text.lua
32
gfx/text.lua
@ -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
|
Loading…
x
Reference in New Issue
Block a user