Bevel button background color not working?

I am trying to create a red colored bevel button, but even with the Has Background Color switch enabled, the chosen color does do anything, the button stays white. A bug or do I still need to do something else to make the button turn red?

You do not realized it cannot works that way when you clicked in the BLACK area to choose the red you want ?

image
Create a png usint the size of your BevelButton and set its color the red you want, then add it using this PopupMenu.
If the result is wrong, use a Canvas instead.

Edit: I was checking Xojo 21r2.1…

Usually, activating “Has Background Color” and then choosing a Background Color does it.

Unbenannt

Are you really using a standard DesktopBevelButton, no Subclass or anything else?

Which platform are you doing this under ?

Which platform ? On Mac, what you see is normal.

1 Like

I did not know this. Thank you @Michel_Bujardet :slight_smile:

HasBackgroundColor As Boolean

If True, the BackgroundColor color will be visible. The BackgroundColor is visible only on Windows and Linux.

Here is how you get the background red on Mac:

Sub Opening() Handles Opening
  var pic as picture = new picture(me.width, me.height)
  pic.Graphics.DrawingColor = &cFF000000
  pic.Graphics.fillRectangle(0, 0, pic.width, pic.height)
  me.Icon = pic
End Sub

3 Likes

I am working on a Mac, yes. Still I think if there is an option that says Background color for a bevel button, it should work. Better would be in this case not to include this option on the Mac version.

Thanks Michael, your way works!

A lot of people (myself included) code on the Mac for other targets.

Using a bevel button instead of a normal push button, the “push animation” is gone. I have set Behaviour to Push Button (not sure if has anything to do with this though). Is there a way to get the “push-animation” on a bevel button?

A yes, you are right, I also work on a Mac and want to release it for Mac and Windows OS.

if you wrap the Mac specific code in #if block then it will only be run in the Mac version. The others will work without it using the background colour.

#if TargetMacOS then
  var pic as picture = new picture(me.width, me.height)
  pic.Graphics.DrawingColor = &cFF000000
  pic.Graphics.fillRectangle(0, 0, pic.width, pic.height)
  me.Icon = pic
#end if
1 Like

Thanks! That’s good to know when releasing for both platforms.

Actually, it isn’t that it won’t run, it won’t even be compiled into the Mac version of the application.

if you need the push animation for all your bevel buttons, here is how to do it:

  • Drag a bevel button on the left hand side pane. It will create a CustomDesktopBevelButton class.
  • Add an event definition “Pressed”
  • Add a method “Push”
  • In the Push method enter the following code:
RaiseEvent Pressed
  • Add the Pressed event
  • In the Pressed event, enter the following code:
RaiseEvent Pressed

Now you can drag customDesktopBevel (you can rename it, for instance MyBevel1) to the window. It will behave like a regular Bevel Button, but you can do the same as with a regular button:

MyBevel1.push