For clarity, this question was closed for a while after I added the clarifying statement inside the parenthesis so I created a new question asking the same thing. This question was later opened and now there are two very similar questions.
I have a panel in which I want to display a few preset colours that a user could then click on but not change the value of (IE, I don't want the colour-picker dialogue to pop up like when clicking a
FloatVectorProperty). When a color is clicked I want to call a function to do some things behind the scenes.
This image from windows paint is basically what I want:
You can use
layout.template_node_socket(color=(R, G, B, A)) but as far as I know there's no way to make it clickable, neither do I think its very good UI wise (I'd much rather have a square).
So my question, is there a way to display a coloured square that's clickable (and calls a function) in the UI?
In this gif from @pyCod3R (using a palette) its showing the colors exactly how I'd like it to be but there is a + and - sign which adds/removes indices to the list. I can't allow users to modify the list because its fixed and no items should be added or removed.
From what I can tell there isn't a way to call a function when a color inside the palette is clicked, am I wrong and there is a way to do it?