Public Sub SetBorder(Node As Node, Width As Double, Color As Paint, CornerRadius As Double)
SetStyleProperty(Node, "-fx-border-color", ColorToHex(Color))
SetStyleProperty(Node, "-fx-border-width", Width)
SetStyleProperty(Node, "-fx-border-radius", CornerRadius)
SetStyleProperty(Node, "-fx-background-radius", CornerRadius)
End Sub
Public Sub GetBorderColor(Node As Node) As String
Return GetStyleProperty(Node,"-fx-border-color")
End Sub
Public Sub GetStyleProperty (Node As Node, Key As String) As String
Dim m As Matcher = Regex.Matcher($"${Key}([^;]+;):"$, Node.Style)
If m.Find Then
Return m.Group(1)
Else
Return ""
End If
End Sub
You can retrieve the button_width withSadly this removes the border that was added in the PropertyBag via the Designer. Usually the nodes have a light gray border sized 1 i think, when I change the border and radius via code to red, radius 2, size 2, I also want to revert back to original light gray size 1. I thought there was an easier way I could quickly do so.
CSSUtils.GetStyleProperty(Button1,"-fx-border-width")
CSSUtils.SetBorder(txtGridLastRow,2,fx.Colors.Red,2)
The 'red' works, I need a way to reset it back to orinal design... thanks anyway...Maybe
B4X:CSSUtils.SetStyleProperty(Button1,"-fx-focus-color","red")
I am setting the border style, color, radius, width via code for each control i.e. red. I want to toggle this via code between the new set style and the default set styles, this code, inside the CSSUtils module does what I want when I set my border etc..When you leave the button it will revert to its original border color.
(it also works for textfields etc)
Public Sub SetBorder(NodeAsNode, Width As Double, Color AsPaint, CornerRadius As Double)
SetStyleProperty(Node, "-fx-border-color", ColorToHex(Color))
SetStyleProperty(Node, "-fx-border-width", Width)
SetStyleProperty(Node, "-fx-border-radius", CornerRadius)
SetStyleProperty(Node, "-fx-background-radius", CornerRadius)
End Sub
.button {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
-fx-background-insets: 0 0 -1 0, 0, 1, 2;
-fx-background-radius: 5, 5, 4, 3;
-fx-padding: 0.166667em 0.833333em 0.25em 0.833333em; /* 2 10 3 10 */
-fx-text-fill: -fx-text-base-color;
-fx-alignment: CENTER;
-fx-content-display: LEFT;
}