DesktopColorPicker: Open event - DesktopTextArea - color change

The ColorPicker can be opened with a contextual-click:Font:Show Colors without affecting the color of the text selected in a DesktopTextArea.

Opening the ColorPicker using the language changes the color of the selected text. Is there a way to avoid this change when the picker is opening?

macOS: Tahoe 26.5, Xojo: 2026 1.2

ColorPickOpen.zip (6.7 KB)

Followup: Found a way using the DesktopColorPicker. It does not work with Color.SelectedFromDialog

Var ss As Integer = ta1.SelectionStart
Var sl As Integer = ta1.SelectionLength
ta1.SelectionLength=0

ColorPicker1.Show(Color.Green, “Choose a color:”)

ta1.SelectionStart=ss
ta1.SelectionLength=sl

Maybe pass the current TextArea.SelectionTextColor as another option? You might still end up setting the color in a roundabout way, but you’d be using the currently selected text’s color to do so.

ColorPicker1.Show(ta1.SelectionTextColor, "Choose a color:")

Right now, your code is telling the color picker “my selection is already green.”

Edit: Confirmed through testing that the above works just fine with the posted sample project. Now, the Color Picker even opens with the correct color too.

Yes, the green was an arbitrary choice. That solution is good unless the selection contains more than one color. In that case all selected text gets the passed color (nil is not an option).

Another slight distraction: the picker gets the focus, so the user has to click back in the TextArea…