I created a popup menu in my main component to trigger another window. When I click on that “create button” on my popup menu , it creates a new window. when i click on “close button” on that created window, it also works fine but the problem is : when i click on that create button again , it always creates another window. I tried to call closebuttonPressed() method before create a window, so it would delete the previous one before creating a new one. But it always returns a nullputr. At first i thought that it was because of that it has not created yet . So i put a flag to make sure that it is created at least once. Again it worked. İ got my first window, then clicked again. code tried to call closebuttonPressd method and it is still nullptr. The same thing happened when i tried to call deconstructor method of that window. My question is how can i delete a window in my code by calling a method ? closeButtonPressed, delete windowname, windowname.deleteandZero didnt work. they always return a nullptr even when a window is already created on the screen .
I noticed the closeButtonPressed()
method actually sends an assertion (if you’re in debug mode this stops the program), and forces you to override it in order to handle the close yourself.
This is probably what you want to do - I’m guessing you might be using DocumentWindow
type, and if you look in the Documentation, or the JUCE Source Code you see that you need to override it.
Try that and see how it goes.
Thank you
in my header file i created a shell by inheriting from public DocumentWindow
SafePointer<VersionWindowShell> versionWindowShell;
In cpp file of main component when I click on create button it checks whether it is created previously or not. If it is already created ,then it calls "closeButtonPressed() and then creates a new window. if it is not , it creates a new window.
if (versionWindowShell!=nullptr) { versionWindowShell->closeButtonPressed(); }
versionWindowShell = new VersionWindowShell("About", Colours::grey,DocumentWindow::allButtons);
it is working , but i noticed that when it displays the new window, it stops painting the main component. When I move the new window ,then main component starts to call paint() function again . I don’t know if it is a commonly encountered issue, but i hope it is, and i hope someone knows how to fix it I tried to put repaint() in some places that i thought it might work but it didn’t. Any suggestions?