Implicid instance

Paul Lefebre wrote (2015):
https://forum.xojo.com/t/window-open-event-is-called-in-window-close-event/

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.

When Implicit Instance is off, calling a window method when the window is closed opens it again. To avoid this I found the only way is as the following example, beause if not Hide it shows it, and if not closed it opens a new instance for every call.

Am I missing somethig (other that putting the method in a module)

Sub Action() Handles Action
  var w as new window2
  w.Hide
  w.doSomething
  w.close
End Sub

its because the visible option is true by default in inspector

Implicit Instance is convenient but is the cause of many headaches. In 20 years of Xojo consulting I almost always turned them off. Implicit Instance is Evil | BKeeney Briefs

4 Likes

i turn it off when i need more than one window of it
or if me need position the window where i want.

the problem here seems the default visible property in form designer.

in this case here i ask me why you need a window

var w as new window2
    w.Hide
    w.doSomething
    w.close

The floating window offers some facilities (objects) that may be placed on the main window, those objects once in the main window may be repositioned and this use methods of the window. Even if these objects should be placed and repositioned with the floating window opened, the user may close it, and continue reposition these objects, and this opens again the floating window.

I see the best approach would be moving some of these window methods to a module.

Thanks for your interest.

or try and set visible of your window to false in designer and at other places you have to show it.
preferably encapsulate your business logic into classes.

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