-
Notifications
You must be signed in to change notification settings - Fork 3
Text Object (Cobalt UI)
ebernerd edited this page Aug 14, 2016
·
4 revisions
The text object is what displays text on the screen. It wraps to the width of its parent, or its margins. You can use the wrap
attribute to tell the object how it should align (left
, center
, or right
).
To add a text object to an object (i.e., Panel
), you use the function Panel:add( "text", {} )
, where {}
is your data table.
-
x
- x position relative to the parent -
y
- y position relative to the parent -
text
- text to display -
foreColour
- colour that the text should display -
backColour
- colour that the text should display in front of (i.e., a highlight) -
wrap
- determines how the the text should wrap (left
,right
, orcenter
) -
marginleft
- the left margin, relative to the parent -
margintop
- the top margin, relative to the parent -
state
- determines if the object should draw, depending oncobalt.state
. Useful for multi-screen apps. Default is its parent'sstate
.
-
:setMargins( top, left )
- sets the margins -
:resize()
- though called internally, this function adjusts the margins and sizes based on the parent's size
local cobalt = dofile( "cobalt" )
cobalt.ui = dofile( "cobalt-ui/init.lua" )
local Panel = cobalt.ui.new({ w = "50%", marginleft="25%", h = "50%", margintop = "25%" })
local Text = Panel:add( "text", { text="I'm a text object!", wrap="center", margintop="50%" } )
function cobalt.draw()
cobalt.ui.draw()
end
cobalt.initLoop()
Result:
This project has been retired. Please view Cobalt 2.