B4J Question css question

ivanomonti

Expert
Licensed User
Longtime User
è possibile impostare css anche per le sezioni dell'oggetto in questione?

is it possible to set css also for the sections of the object in question?

B4X:
Sub css_button(obj As Button)
    CSSUtils.SetStyleProperty (obj,"-fx-base"," #222222")
    CSSUtils.SetStyleProperty (obj,"-fx-control-inner-background","#222222")
    CSSUtils.SetStyleProperty (obj,"-fx-background-color","#222222")
    CSSUtils.SetStyleProperty (obj,"-fx-table-cell-border-color"," transparent")
    CSSUtils.SetStyleProperty (obj,"-fx-table-header-border-color"," transparent")
    CSSUtils.SetStyleProperty (obj,"-fx-padding","5")
    CSSUtils.SetStyleProperty (obj,"-fx-font-size","10pt")
    CSSUtils.SetStyleProperty (obj,"-fx-text-fill","#7D7D7D")
    CSSUtils.SetStyleProperty (obj,"-fx-border-width","0")
    CSSUtils.SetStyleProperty (obj,"-fx-background-radius","0")
    CSSUtils.SetStyleProperty (obj,"-fx-background-insets","0 0 0 0, 0, 1, 2")
End Sub

Error code

B4X:
CSSUtils.SetStyleProperty (obj,".button:hover:-fx-background-color"," #3a3a3a")
CSSUtils.SetStyleProperty (obj,".button:pressed, .button:default: hover:pressed -fx-background-color: white;-fx-text-fill"," #1d1d1d")
 

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
Why you don't use style sheets and selector id?

B4X:
'MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "style.css"))

Sub css_button(obj As Button)
        obj.Id="btnstyle1"
End Sub

style.css
HTML:
#btnstyle1 {-fx-control-inner-background: "#222222";}
#btnstyle1 {-fx-background-color: "#222222";}
#btnstyle1 {-fx-table-cell-border-color: "transparent";}
#btnstyle1 {-fx-table-header-border-color: "transparent";}
#btnstyle1 {-fx-padding: 5;}
#btnstyle1 {-fx-font-size: 10pt;}
#btnstyle1 {-fx-text-fill: "#7D7D7D";}
#btnstyle1 {-fx-border-width: 0;}
#btnstyle1 {-fx-background-radius: 0;}
#btnstyle1 {-fx-background-insets: 0 0 0 0,0, 1,2;}
#btnstyle1:hover {-fx-background-color: "#3a3a3a"}
#btnstyle1:pressed {-fx-background-color: white; -fx-text-fill: "#1d1d1d"}
 
Last edited:
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
No. The style of classes must be set in the CSS file. Once you do it you will see that it is very simple.

I would like to do an inner class for personal management, it is not possible so you are telling me!
 
Upvote 0
Top