Skip to content
newk5 edited this page Apr 7, 2020 · 3 revisions

The canvas has the exact same properties as the default GUICanvas but adds other new properties and functions aswell.

New properties and functions

.autoResize - boolean // when true the canvas will resize itself automatically to fit its content
.children - array of GUIElements
.addBorders(border) - function //adds top, left, right and bottom borders to the canvas, example border table: { color = Colour(255,255,255), size = 2 }
.removeBorders() - function //deletes all canvas borders
.updateBorders() - function // updates the canvas borders (should be used when the dimensions of the canvas change) 
.addLeftBorder(border) - function // adds left border
.addRightBorder(border) - function // adds right border
.addTopBorder(border) - function // adds top border
.addBottomBorder(border) - function // adds bottom border
.add(child) - // replaces the default .AddChild function and is used to add elements to the canvas
.removeChildren() - function // deletes all children added with .add(child)

Example:

 UI.Canvas({
        id = "canv"
        Size =VectorScreen(350,200)
        align = "center"
        Color = Colour(150,150,150,250)
        children = [
            UI.Button({
                id      ="btn"
                align   = "center"
                Size    = VectorScreen(100,30)
                Colour  = Colour(220,0,0)
                Text    = "Change label"
                onClick = function() {
                    UI.Label("lbl").Text = UI.Editbox("input").Text;
                }
                onHoverOver = function() {
                   this.Colour = ::Colour(0,150,0);
                }
                onHoverOut  = function() {
                    this.Colour =::Colour(220,0,0);
                }
            })
             UI.Editbox({
                id       = "input"
                Position = VectorScreen(125,30)
                Size     = VectorScreen(100,20)
                Colour   = Colour(255,255,255)
                Text     = "This is a label"
            })
            UI.Label({
                id       = "lbl"
                Text     = "This is a label"
                Position = VectorScreen(135,135)
                Color    = Colour(0,0,0)
            })
        ]
    })

Clone this wiki locally