i’ve added a class called “ConfirmButton” that is based on the “TextButton” component. what i’d like to do is only pass a clicked message to the parent component (the one that contains the button in question) when the user clicks the button and then affirms their choice via an alert dialog (or maybe something else, but at the moment it’s an alert dialog).
i can intercept the click method with no problem. i can have the alert dialog pop up and do what i need, but i can’t seem to figure out how to then alert the parent component of the change without hardwiring it. it seems all the message passing stuff is protected/private so i can’t then just jump into standard juce code to handle the approved click message.
here is the code in question:
class ConfirmButton : public TextButton
{
public:
ConfirmButton ( const String& name,
const String& toolTip = String::empty,
AlertWindow* dialog = NULL)
: TextButton(name, toolTip)
{
confirmDialog = dialog;
setClickingTogglesState(false);
};
/** Destructor. */
~ConfirmButton()
{
}
void clicked()
{
confirmDialog->setCentreRelative(0.5f,0.5f);
confirmDialog->setAlwaysOnTop(true);
int v = confirmDialog->runModalLoop();
if (v)
{
setToggleState(true, false);
}
confirmDialog->setVisible (false);
}
private:
Component *confirmDialog;
};
the setToggleState function can’t alert the button that it’s changed or i’ll end up back in the click() routine, so i have to pass it false for the notification flag.
thoughts?