# Paste & set color with a single button (for palettes)

I need to use some colors frequently so I decided to make a palette for this. This is an example palette button that inserts a color:

CreatePalette[PasteButton[RGBColor[.5, .6, .7], RGBColor[.5, .6, .7]]]


But I may also want to set some text inside a non input cell to that color. So for that this works:

CreatePalette[
Button[RGBColor[.5, .6, .7],
FrontEndExecute[{FrontEndToken[
SelectedNotebook[],
FontColor,
RGBColor[.5, .6, .7]]}]]]


or

CreatePalette[
Button[RGBColor[.5, .6, .7],
CurrentValue[NotebookSelection[InputNotebook[]], FontColor] = RGBColor[.5, .6, .7]]]


But I don't want two create two buttons for each color. I prefer to have a single button that inserts a color if nothing is selected (1st case) or styles some text is there is a selection.

This is what I have tried to do (but it does not work):

CreatePalette[
Button[RGBColor[.5, .6, .7],
If[CurrentValue["SelectionData"] == \$Failed,
NotebookWrite[ButtonNotebook[], RGBColor[.5, .6, .7]],
FrontEndExecute[{FrontEndToken[InputNotebook[], FontColor, RGBColor[.5, .6, .7]]}]]]]


Can this be solved?

CreatePalette[Button["Crazy Color Palette",