Fixing ContainerControls sample

I’m new to Xojo and I’m watching the webinars and reading the docs. Today I watched ‘Using ContainerControls in a Desktop App’ and loaded the TabbedWebBrowser sample.

The one that came with 2017r1 is much better than the one in the video but one thing bugged me, if I delete a Tab, when I add it again the name change from ‘Untitled’ to whatever name it had before closing.

Let’s say that I open 5 tabs, and number 3 title is Google and the others Untitled. If I remove Google tab I expect to get 4 Untitled tabs, but I get 2 Untitled, then Google (but blank webpage) and another Untitled.

It was a good first exercise to see what the code do and what is happening.

I was able to test some things and finally I think this code is missing from the CloseTab:

mBrowserTabs.Remove(BrowserTabPanel.Value)

I tested it and it works as expected. Is that the right way to do it? Thanks.

I did my tests with the following code in CloseTab method:

BrowserTabPanel.Remove(BrowserTabPanel.Value) mBrowserTabs.Remove(BrowserTabPanel.Value)

I don’t know why it worked as expected. The only way it doesn’t work is when I delete the far right tab first. Whatever title it has is transferred to the next tab (now the far right tab).

As soon as BrowserTabPanel.Remove executes the BrowserTabPanel.Value is lowered by 1.

If I change the code to:

mBrowserTabs.Remove(BrowserTabPanel.Value) BrowserTabPanel.Remove(BrowserTabPanel.Value)

Everything works.

I added an IF statement that check if there is only 1 Tab, that way I can’t clic ‘Close Tab’ when there are none. The app stop running and I get a nice bug icon on the left side of the first line in CloseTab method.

Mac 10.12.6

I installed Xojo2017r11 on a Windows 7 machine, ran the sample and the behavior (tab selected) is different from a Mac.

Mac: when I run the app, even if I close the far right tab, automatically the next tab is selected. I can keep closing tabs until I have one (thanks to the IF code I added).
Windows: when I run the app and close the far right tab, then there is no tab selected. At that point if I clic ‘Close Tab’ again the debug show an error ‘OutOfBoundsException’

BrowserTabPanel.Value is equal to -1 when no Tab is selected. Is this always the case?
I added an IF to check if the value is < 0 and show a msgBox.

Do you know if the difference is because the internal OS code or it is something coded differently in Xojo Mac and Xojo Windows?

Another thing with Windows: the BrowserToolbar, when run, there is no a blank space between ‘Forward’ and ‘Refresh’, nor between ‘Refresh’ and ‘New Tab’ but there is ToolItem1 and ToolItem2 there, Size Enabled On and Style Space.
Can you confirm if this is happening with other installations?

Thank you