DocumentWindow's close button

Hello!
When I create DocumentWindow instance, the close button on it does not closes a window. So I try to assign the lamba in a following way:

juce::DocumentWindow *wnd_fx;
juce::Button *bt_fx_close;
...

bt_fx_close = wnd_fx->getCloseButton();
if (bt_fx_close)
   {
     bt_fx_close->onClick = [this] {
                             std::cout << "CLOSE PRESSED" << std::endl;
                             };
     }

But onClick is not works :frowning:

You’d typically override juce::DocumentWindow::closeButtonPressed() and call JUCEApplicationBase::quit().

https://docs.juce.com/master/classDocumentWindow.html#a71c46283a6fe63f2cad49d01997e16d5

1 Like

But what if I want to use DocumentWindow as is? Is close button cannot be reachable for assigning the onClick lambda?

I didn’t even know you could instantiate juce::DocumentWindow tbf, I’d always assumed it was an abstract type. I really wouldn’t recommend doing that though.

Assigning to the close button’s onClick method may work if you’re using a non-native title bar, but it almost certainly won’t work for the native buttons - hense why the closeButtonPressed() method exsists so you can be notified when either type of button is pressed.

Why do you want to use DocumentWindow as-is, out of interest?

1 Like

Thank you for advice! I’ve made the subclass of DocumentWindow and overrided closeButtonPressed(). I need a sort of the pop-up window with FX properties. CalloutBox was non-obvious for me, so I decided to use DocumentWindow instead, as a holder of an actual content component with several widgets.