PropertyComponent subclass


#1

I’m trying to create 2 custom property components, i did one and it’s working with one but. Everytime i click on the component (it’s a colour selector) the PropertyPanel deletes my PropertyComponent and re-creates it, so i don’t have fluid mouse movement. The deletion happens only if i change the Value that is passed to the PropertyComponent constructor. It’s very simple but i guess i’m missing something very obvious as usual:

CtrlrColourPropertyComponent::CtrlrColourPropertyComponent (const Value &v, const String &propertyName)
	: PropertyComponent (propertyName), val(v), cs(ColourSelector::showColourspace)
{
	preferredHeight = 128;
	addAndMakeVisible (&cs);
	cs.addChangeListener (this);
}

CtrlrColourPropertyComponent::~CtrlrColourPropertyComponent()
{
}

void CtrlrColourPropertyComponent::refresh()
{
	cs.setCurrentColour (Colour::fromString (val.toString()));
}

void CtrlrColourPropertyComponent::changeListenerCallback (ChangeBroadcaster* source)
{
	val = cs.getCurrentColour().toString();
}

#2

A PropertyPanel doesn’t have the power to re-create the PropertyComponents; it doesn’t know (or care) what derived classes they might be, so has no means of instantiating them. The only way a PropertyComponent instance makes its way onto a PropertyPanel is by placing it there yourself. If a new PropertyComponent is actually appearing in the PropertyPanel, it sounds like perhaps you’re re-populating the panel as a result of a change notification.


#3

you are right, my value change was triggering a change in the components thus changing the selection, thus changing the propertyPanel, it was invisible to me but was happening.

thank you.