window open event is called in window close event

in the main window open event I call a method to load a listbox.
Exiting the application, I use self.close from the main windows toolbar menu,
I noticed that the main windows open event runs again and then closes the application,
why does it run after self.close ?

I am going to guess you have “Implicit Instance” set to YES for the window and are referring to it by name in your code somewhere. Referring to the window by its name will cause it to open. Either do not refer to it by name after you have closed it, or turn off Implicit Instance and keep your own instance around to use.

Paul your guess was right. I never paid much attention to implicit instance of an window, it was just very convenient to use.
What I have to do now is instantiate my main window once with NEW and use this reference throughout the application,
right ? searching in the forum is telling me the same as you did.

thanks Paul

I changed to a global reference of the main window, everything works fine except closing the application.
until now I used to do a mainwindow.close and the application finished (button in toolbar button)
Now I have to click that button twice to close the application.
How can I close the application properly ?

found the problem, main window was displayed twice.
main-window was also the default window of the application.
I opened it in app.open event and the application opened it because of the default setting.
I changed the default to none and now it work as it should.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.