Opacity slider in "choose color" color picker

Here it is - the best solution to the problem. Thank you, Shane.

(Eight posts of squabbling and insult hurling deleted by moderator.)

Thank you very much to everyone for helping me out. I apologize to KniazidisR for not paying enough attention to the details in your posts.

I’ve released my Visual Studio Code extension today:
https://marketplace.visualstudio.com/items?itemName=dae.vscode-mac-color-picker

However, I’ve decided not to use the suggested script and keep “choose color” because:

  1. “choose color” can have a “default” (starting) color and this is essential to the functionality of my extension.

  1. NSColorPanel invoked via the script posted here feels slightly less responsive to mouse clicks.

  2. NSColorPanel invoked via “choose color” has OK and Cancel buttons, which are very convenient.

I figured out I could strip the alpha channel value before feeding the color to the color picker, and restore it when the user closes the picker. In other words, if the user selects the following:

rgba(255, 255, 255, 0.5)

The extension would save 0.5 and send only {65 535, 65 535, 65 535} to the color picker. When the user hits OK, the extension converts the color back to rgba(…) notation with the previously saved alpha channel value.

I thought it’d be fair to post an update.

Once again, thank you!