LucaMs Expert Licensed User Longtime User Dec 30, 2015 #1 Is there a direct way to set the background color of "views"? (or a better solution compared to the following, which I do not like "too much") I wrote and suggested these two routines (and you could suggest better names for them ) I'm not devoting time to b4j, only to a server without GUI, then I'm not an expert, absolutely. Code: Copy Button1.Style = SetStyleBackground(fx.Colors.Red) ... ' "SetStyle" because I thought to pass the "view" Sub SetStyleBackground(Color As Object) As String Return "-fx-background-color:" & StyleColorString(Color) End Sub Sub StyleColorString(FXColor As String) As String Return "#" & FXColor.SubString(2) & ";" End Sub [Also, probably there is a method to pass "views" as parameters and...] Last edited: Dec 30, 2015
Is there a direct way to set the background color of "views"? (or a better solution compared to the following, which I do not like "too much") I wrote and suggested these two routines (and you could suggest better names for them ) I'm not devoting time to b4j, only to a server without GUI, then I'm not an expert, absolutely. Code: Copy Button1.Style = SetStyleBackground(fx.Colors.Red) ... ' "SetStyle" because I thought to pass the "view" Sub SetStyleBackground(Color As Object) As String Return "-fx-background-color:" & StyleColorString(Color) End Sub Sub StyleColorString(FXColor As String) As String Return "#" & FXColor.SubString(2) & ";" End Sub [Also, probably there is a method to pass "views" as parameters and...]
Erel B4X founder Staff member Licensed User Longtime User Dec 30, 2015 #2 You can set the background color with the designer. Your code will overwrite the existing style so it will remove the other style attributes set by the designer or developer. The background color is set with a CSS style. Upvote 0
You can set the background color with the designer. Your code will overwrite the existing style so it will remove the other style attributes set by the designer or developer. The background color is set with a CSS style.
LucaMs Expert Licensed User Longtime User Dec 30, 2015 #3 Erel said: You can set the background color with the designer. Your code will overwrite the existing style so it will remove the other style attributes set by the designer or developer. Click to expand... I know, but that is the choice of an italian member, set (probably not change) the color through code. Thank you Last edited: Dec 30, 2015 Upvote 0
Erel said: You can set the background color with the designer. Your code will overwrite the existing style so it will remove the other style attributes set by the designer or developer. Click to expand... I know, but that is the choice of an italian member, set (probably not change) the color through code. Thank you
LucaMs Expert Licensed User Longtime User Dec 30, 2015 #4 The "ideal" would be something like: SetBGColor(MyView, FX.Color.Red) "You" should "only" write here the missing routine SetGBColor [Note: "you" does not mean at all "you Erel"] Upvote 0
The "ideal" would be something like: SetBGColor(MyView, FX.Color.Red) "You" should "only" write here the missing routine SetGBColor [Note: "you" does not mean at all "you Erel"]
LucaMs Expert Licensed User Longtime User Dec 30, 2015 #5 Is this correct? Code: Copy ' Sets the background color of a Node ' Color: pass a "JFX.Color" object Sub SetBGColor(MyNode As Node, Color As Object) Dim strColor As String = Color MyNode.Style = "-fx-background-color:" & "#" & strColor.SubString(2) & ";" End Sub Last edited: Dec 30, 2015 Upvote 0
Is this correct? Code: Copy ' Sets the background color of a Node ' Color: pass a "JFX.Color" object Sub SetBGColor(MyNode As Node, Color As Object) Dim strColor As String = Color MyNode.Style = "-fx-background-color:" & "#" & strColor.SubString(2) & ";" End Sub
LucaMs Expert Licensed User Longtime User Dec 30, 2015 #6 Last question (I should open a new thread, I know, but I need only a "yes" or "not"): Can I get all the properties of a Node set by Designer and saved in a CSS file? (if so, I could write a list of MyNode.Style lines). P.S. I fear there are no CSS files created by Designer, but it is incorporated some way in the layout file. Upvote 0
Last question (I should open a new thread, I know, but I need only a "yes" or "not"): Can I get all the properties of a Node set by Designer and saved in a CSS file? (if so, I could write a list of MyNode.Style lines). P.S. I fear there are no CSS files created by Designer, but it is incorporated some way in the layout file.
Erel B4X founder Staff member Licensed User Longtime User Dec 30, 2015 #7 LucaMs said: It this correct? Click to expand... Not 100%. See the implementation in CSSUtils: https://www.b4x.com/android/forum/threads/class-cssutils.61824/ You can see what the designer adds with Log(Node.Style). Upvote 0
LucaMs said: It this correct? Click to expand... Not 100%. See the implementation in CSSUtils: https://www.b4x.com/android/forum/threads/class-cssutils.61824/ You can see what the designer adds with Log(Node.Style).
LucaMs Expert Licensed User Longtime User Dec 30, 2015 #8 Erel said: Not 100%. See the implementation in CSSUtils: https://www.b4x.com/android/forum/threads/class-cssutils.61824/ You can see what the designer adds with Log(Node.Style). Click to expand... If I had known this, I would have recommended your class immediately, without consuming my two neurons Thank you, Erel Upvote 0
Erel said: Not 100%. See the implementation in CSSUtils: https://www.b4x.com/android/forum/threads/class-cssutils.61824/ You can see what the designer adds with Log(Node.Style). Click to expand... If I had known this, I would have recommended your class immediately, without consuming my two neurons Thank you, Erel
LucaMs Expert Licensed User Longtime User Dec 30, 2015 #9 LucaMs said: If I had known this Click to expand... It is NEW!!! Wonderfull! Upvote 0