M Mostez Well-Known Member Licensed User Longtime User Mar 9, 2024 #1 I want to style a specific button differently from the others in style file, to draw the user's attention before they click it. For example, to change the text color, background color, or hover color to red. how to do that? TIA
I want to style a specific button differently from the others in style file, to draw the user's attention before they click it. For example, to change the text color, background color, or hover color to red. how to do that? TIA
Daestrum Expert Licensed User Longtime User Mar 9, 2024 #2 Set the controls ID then you can select it directly in a css file with #YourControlsID. B4X: Button1.As(JavaObject).RunMethod("setId",Array("Button1")) MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "mycss.css")) ' css file mycss.css #Button1:hover{ -fx-background-color: red; -fx-background-insets: 0 0 -1 0, 0, 1, 2; -fx-background-radius: 3px, 3px, 2px, 1px; -fx-padding: 0.333333em 0.666667em 0.333333em 0.666667em; /* 4 8 4 8 */ -fx-text-fill: -fx-text-base-color; -fx-alignment: CENTER; -fx-content-display: LEFT; } Upvote 0
Set the controls ID then you can select it directly in a css file with #YourControlsID. B4X: Button1.As(JavaObject).RunMethod("setId",Array("Button1")) MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "mycss.css")) ' css file mycss.css #Button1:hover{ -fx-background-color: red; -fx-background-insets: 0 0 -1 0, 0, 1, 2; -fx-background-radius: 3px, 3px, 2px, 1px; -fx-padding: 0.333333em 0.666667em 0.333333em 0.666667em; /* 4 8 4 8 */ -fx-text-fill: -fx-text-base-color; -fx-alignment: CENTER; -fx-content-display: LEFT; }
M Mostez Well-Known Member Licensed User Longtime User Mar 9, 2024 #3 works great, thank you so much Upvote 0