AddClass command - Forum

Forum Navigation
You need to log in to create posts and topics.

AddClass command

H to all.

I can use the SetObjectCSS command, but I have difficulty using AddClass.
What are the differences, can you give me an example?

Regards

@giasal if you intend to use AddClass command you must first write the CSS class under Project > Properties > Styles
For example if you write there this CSS class:

.myclass{
   color:red;
}

Then you can use this command whenever you want an object to show red text:

AddClass "Container1" "myclass"

I hope it helps.

GiaSal has reacted to this post.
GiaSal

@giasal

When you want to dynamically add style properties/values to an object, use SetObjectCSS e.g. from the Help file ...

CreateEmptyObject [myCSS]
SetVar [myCSS("left")] "+=200"
SetVar [myCSS("top")] "+=100"
SetVar [myCSS("width")] "+=100"
SetVar [myCSS("height")] "+50"

SetObjectCSS "Container1" [myCSS]

When you want to apply a previously defined css class (category) that was defined in your project via Project>>> Properties >>> Styles, like so ...

.creditsButton {
background-color: #EF2447;
border: none;
color: white;
padding: 2px 4px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 2px 2px;
cursor: pointer;
}

... to be applied to an object, then use AddClass e.g. ...

 

AddClass "PushButton1" "creditsButton"

Note: do not use the dot prefix in the command; it is used in the css definitions to identify it as a class definition.

luishp and GiaSal have reacted to this post.
luishpGiaSal