Making ColorSetter work like a PasteButton
Here is a solution.
I have made 2 modifications on your code:
ButtonPaste[]
replaced by Button[]
(the Attributes are not the same)
Setting[]
(useless) replaced by Paste[]
Full code :
Grid[{{
Button[
Graphics[{Dynamic[col], Rectangle[]}, ImageSize -> 26],
Paste[col],
ImageSize -> 26,
ImageMargins -> 0,
FrameMargins -> 0],
ColorSlider[
Dynamic[col],
ImageSize -> {75, 25},
AppearanceElements -> "Spectrum"
]
}},
Spacings -> 0,
Alignment -> Bottom
]
Button[]
has the attribute HoldRest
(ButtonPaste[]
has not), so the col
(of Paste[col]
) is only evaluated when the Button is clicked.
If you wrap your entire widget (as currently shown in your code), in Dynamic
, it will work. The reason is that without it, changes is col
are not propagated to PasteButton
.