How to get selected colour before the Color.SelectedFromDialog window is closed?

In the Xojo IDE on macOS, clicking the colour selection button opens an OS colour selector that looks just like the one that we get from Color.SelectedFromDialog or SelectColor.

However, the relevant control in the IDE updates its colour as you fiddle with the sliders, etc (on macOS at least, I haven’t tested this in the Windows version of the IDE). Unless I’m missing something, this isn’t possible with Color.SelectedFromDialog or SelectColor, where you have to wait for the result until the window is closed.

Am I missing some kind of asynchronous option for Color.SelectedFromDialog or SelectColor? Or is the Xojo IDE using a different approach that’s not available to us?

PS: I know that NSColorPanelMBS is available for macOS, I’m trying to find a macOS & Windows solution if one’s available in Xojo.

the color is byref here, it should be the returning value at result true
result = Color.SelectedFromDialog(ByRef col,
means the col argument get overwritten
https://documentation.xojo.com/api/graphics/color.html#color-selectedfromdialog

Thanks, Markus: that’s how I’m using Color.SelectedFromDialog() at the moment, but my point was that this doesn’t seem to be what the Xojo IDE uses because it’s updating the selected colour in the IDE as you change values within the colour picker.

ahh, sorry. i had read half.
you like to have a change event if the color was choosen if this dialog is open.
This SelectedFromDialog is a Modal dialog and stops execution.

System.DebugLog "Before Dialog"
Var c As Color = Color.Red
Call Color.SelectedFromDialog(c, "Select a Color")
System.DebugLog "After Dialog"

you could create your own color choose window with a change event.

This would often irritate users (and waste your time, by the way).
But I’m sure there are declares (on Mac OS) to have the asynchronous version.
I don’t know whether Windows and Linux actually support an asynchronous version as well.

1 Like

Thanks for the suggestions! In this case, I think the user experience would be better if the selected colour was updated immediately in my app’s GUI because that would help users to select a colour scheme. Currently, the workflow is:

  1. Use the select colour command to open the colour picker.
  2. Select a colour.
  3. Close the colour picker.
  4. Wait up to a couple of seconds for Xojo to move onto the next line of code… (there seems to be some lag with Color.SelectedFromDialog and SelectColor, but I’ve never been able to replicate it in a simple test project).
  5. Do I like the colour I picked? If not, goto 1.

If you use GraffitiSuite, Anthony added a custom cross platform asynchronous color selector.

2 Likes

Thanks, Tim: that’s just the kind of live updating functionality that I’m looking for.