Skip to content

GUILabel

newk5 edited this page Apr 21, 2020 · 3 revisions

GUILabels in DecUI work exactly the same way they work when not using DecUI. However, when using labels with automatic wrapping enabled (wrap = true), every time you want to change a property value, you must use the .set(field,value) function instead of accessing the properties directly. For example, instead of doing: label.FontSize = 12; you do: label.set("FontSize",12);. You have to do this for every property you want to change (.FontSize, .Text, .TextColour, etc.. )

To create a label using automatic wrapping you do the following:

UI.Label({
    id = "lbl"  
    TextColour = Colour(255,255,255)
    FontSize = 11
    Text = "DecUI (declarative UI) is a library to create VCMP GUI's in a declarative manner. It also provides many lower level abstractions and some new components and features. All of the existing properties and functions will still work so everything listed on the VCMP wiki is still applicable. This library provides new functions and properties in addition to the current ones listed on the VCMP wiki aswell as a few new components and a declarative way of creating these components."
    wrap = true
    wrapOptions = {
         lineSpacing = 5
         maxWidth = 100 //you dont need to specify this since DecUI will use the parent size by default, only use it if you want to use a different value than the parent size
    }
})

If you're not creating a label that uses automatic line wrapping you should still using the .set(field,value) function when changing a label text( use label.set("Text","label text here") instead of label.Text = ... ) due to the VCMP bug happening with labels where the label size is not changed whenever the text changes to a smaller text.

Example

local tv = UI.TabView({

       id="tabview",
       align = "center",
       Size = VectorScreen(400,300), 
       onTabClicked = function(t){
          Console.Print(t +" tab clicked");
       }, 
    
       tabs = [
           {  
               title = "tab1",
               content = [ 
                    UI.Label({
                        id = "lbl"  
                        TextColour = Colour(255,255,255)
                        FontSize = 11
                        Text = "DecUI (declarative UI) is a library to create VCMP GUI's in a declarative manner. It also provides many lower level abstractions and some new components and features. All of the existing properties and functions will still work so everything listed on the VCMP wiki is still applicable. This library provides new functions and properties in addition to the current ones listed on the VCMP wiki aswell as a few new components and a declarative way of creating these components."
                        wrap = true
                        wrapOptions = {
                            lineSpacing = 5
                        }
                    })
                  
                   
               ]
               
           },
           { title = "tab2"  }
          
       ]
}); 

Clone this wiki locally