mos Posted September 25, 2020 Share Posted September 25, 2020 I have the following code: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniButton1.Color := clRed; end; However the button color does not change. How can I change the background color? Link to comment Share on other sites More sharing options...
x11 Posted September 25, 2020 Share Posted September 25, 2020 may be CSS? Link to comment Share on other sites More sharing options...
x11 Posted September 25, 2020 Share Posted September 25, 2020 http://forums.unigui.com/index.php?/topic/14107-using-css/ Link to comment Share on other sites More sharing options...
mos Posted September 25, 2020 Author Share Posted September 25, 2020 I need to change the background color at runtime based on the user that has logged in. In other words I need to be able to change it dynamically. Link to comment Share on other sites More sharing options...
Sherzod Posted September 25, 2020 Share Posted September 25, 2020 5 minutes ago, mos said: I need to change the background color at runtime based on the user that has logged in. In other words I need to be able to change it dynamically. Also this post may help you: 1 Link to comment Share on other sites More sharing options...
Abaksoft Posted January 12, 2021 Share Posted January 12, 2021 Try this : Project1.7z Link to comment Share on other sites More sharing options...
Abaksoft Posted January 12, 2021 Share Posted January 12, 2021 Hello Sherzod, If i use a more simple method (CSS), i have the result : Putting this CSS on ServerModule > CustomCSS and bg on Unibutton1 > LayoutConfig > CLS 1. This gives the color .bg { background-image: none; background-color: green; } 2. This Not : .bg { background-color: green; } 3. If I use a big font then it overlaps How can i avoid overlap ? Thx Link to comment Share on other sites More sharing options...
Sherzod Posted January 12, 2021 Share Posted January 12, 2021 21 minutes ago, Abaksoft said: 3. If I use a big font then it overlaps How can i avoid overlap ? Hi Mohammed, Can you try: 1 Link to comment Share on other sites More sharing options...
Abaksoft Posted January 12, 2021 Share Posted January 12, 2021 Many thx Sorry for the inconvenience. 1 Link to comment Share on other sites More sharing options...
Abaksoft Posted January 13, 2021 Share Posted January 13, 2021 Hello Unigueers, Please Share your expertise ! Many of us don't share any thing, probably thinking it's elementary. it's wrong ! I keep saying : "Share, Share, Share and more" ... even if it's simple. --> This will save us a lot of time. So, for Who just come to Unigui world, here is a simple way do set dynamically (at runtime) the Unibutton color Background. Color Background, say you ? Yes ... as it's not obvious at all (thx to Sherzod) : with UniButton1.JSInterface do begin JSCall('btnWrap.setStyle', ['background-image', '"none"']); JSCall('btnWrap.setStyle', ['background-color', 'rgb(0,128,128)']); end; You can use : https://www.w3schools.com/css/css_colors_rgb.asp To convert Colors in rgb and rgba format (a = Alpha = Transparency). 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now