Changing Window When Loading Startup Window

  1. 4 years ago

    ingurgite

    13 Aug 2019 User since 2018

    Hi,

    I am storing in the local database the name of the last visited page to bring the user back to it when reopening the app. Is there a way to do something like this? What I did so far (but it did not work):

    In the Startup Windows and WillShow() event, I put something like that:

    if (metadata.screen == "read")
    	Read.open()
    else if (metadata.screen == "browse")
    	Browse.open()
    ...

    Any idea?

    Thanks

  2. marco

    13 Aug 2019 Administrator User since 2016

    Hi @ingurgite you mean in a local sqlite database?
    If yes then you need to do a select statement and then based on the result of your query open the appropriate window.
    If you post more details about the sql schema I'll be happy to help you.

  3. ingurgite

    29 Oct 2019 User since 2018

    Hi @marco,

    The SQL schema is not really relevant. All I want is, based on a value, to load a window instead of the default one. I cannot manage to do this. So far, what I have tried is to put the following code in the WillShow() event callback of the default window:

    var screen = "journal"
    
    if (screen == "journal")
    {
    	console.log("HERE: opening journal")
    	Journal.open()
    }

    Unfortunately, nothing happens.

    Thanks.

  4. marco

    30 Oct 2019 Administrator User since 2016

    @ingurgite when this code is executed? Do you need to replace the default first window with something else? Is that window opened inside a NavigationBar or what?

  5. ingurgite

    30 Oct 2019 User since 2018

    Hi @marco, this code is executed when the app launches, through the WillShow() event.

    What I want is to replace the current (default) window with a new one before it is displayed.

    Currently with the code I showed above, nothing happens. The window is never opened. If I put the code in DidShow() callback, it works however.

    Is there a reason?

  6. andrea

    6 Nov 2019 Administrator User since 2016
    Edited 4 years ago by andrea

    Hi @ingurgite,
    the `Journal.open()` invocation tries to open the Journal in the active container, the default window in this case. The default window should open the Journal window as a modal window but it fails if executed in the WillShow event because a window that is not already added to the window's hierarchy cannot open a modal window.

    A safer way to change the default window could be to use the loadContainer() method of the Application object, for example with the following code:

    var screen = "journal"
    
    if (screen == "journal")
    {
    	console.log("HERE: opening journal")
    	App.loadContainer(Journal)
    }

    This command replaces the root window (default window) with the Journal window.

or Sign Up to reply!