Color picker on Mac

Dim c As Color
Dim b As Boolean
b= Color.SelectedFromDialog(c,“Select a Text Color”)
If b then
label1.TextColor =c
End if
This code works fine on windows while on mac the color picker opens without the OK button. (Xojo vers. 2020 2.1 OS mac Ventura) What can it depend on? from the version of Xojo?

The macOS color picker is asynchronous. You can do what you’re doing, but the “dismiss” action is to close the picker with the close button in the upper left corner.

Instead, try dragging a color picker control to your layout and implement the ColorSelected event. That works on all platforms.

Hi Greg, I apologize for my ignorance, can you explain everything better, consider my bad English, take my code written in the Action event of a button as good as it should allow me to set the color of a label. You report; Try dragging a color picker control to your layout, what do you mean by my layout? I couldn’t find the ColorSelected event in any object. Thank you in advance for your further explanation

I’m assuming that you are using the color picker in conjunction with a Window in your project. Go to the window editor, open the library and drag a color picker onto the Window. It will appear in the tray at the bottom of the window. You’ll need to add the ColorSelected event to that control.

When you want to use it, you’ll do something like this in your code:


Then in the ColorSelected event:

label1.TextColor = selectedColor

More info can be found at:

1 Like

Thank you