I’m attempting to track open windows so that, when users press the BACK button on any window, the current window will close and the previously open window will open again. I have two methods, ScreenAdvance and ScreenBack, stored in a public module and called by prefixing the module name to the Method (e.g., ModuleName.ScreenAdvance(parm1 as window, parm2 as string)).
I have an array in the APP object of type WINDOW called winScrnHistory()
I also have a parallel array in the APP object of type STRING called strScrnHistory()
As I open a new window, the window name is added to the winScrnHistory() array and it’s added as a string to the strScrnHistory() array. As the user closes a window, I remove the UBound element from both arrays.
When the user navigates to a new window, I close the window in the UBound array element:
App.winScrnHistory(UBound(App.winScrnHistory)).Close //close ubound window
I then append the requested window as WINDOW and string to the two arrays and .Show the window as follows:
winNextScr.Show //open new window
All works fine so far.
When the user clicks the BACK button, I call ModuleName.ScreenBack. This Method first closes the currently opened screen with the following:
App.winScrnHistory(UBound(App.winScrnHistory)).Close //close ubound window
That works fine. Then I remove the UBound element from both arrays, which results in a UBound value 1 less than before. I then attempt to open the new UBound window with the following:
App.winScrnHistory(UBound(App.winScrnHistory)).Show
This statement, however is ignored by Xojo. No exception is raised.
When I change the statement to have a specific index such as:
App.winScrnHistory(0).Show
… and that works fine. But, of course, I want to dynamically look at the UBound element of the array and open it, so I can’t hard code the index #.
So I then tried to execute the .Show right after the .Close statement, before removing elements from the array, using this statement:
App.winScrnHistory(UBound(App.winScrnHistory)).Show //REOPEN just-closed ubound window
And that statement was ignored by Xojo also.
Should this not work, or am I using unsupported syntax? Is there a better way to do this?
Thanks for any insight!