Bringing a webcontainer to the front

I have an application that uses several different webcontainers. When I first display one of these webcontainers, or if several webcontainers are visible and the users clicks on a webcontainer that is behind another webcontainer, I would like to bring the webcontainer with the focus to the front. The only way to control order seems to be the zindex property. There does not appear to be any “bringtofront” type method for webcontainers.

Since the frontmost webcontainer has the highest zindex, I have created a webpage-level property called zindexval that holds the highest current zindex value. When I want to bring another webcontainer to the front, I increment the webpage zindexval property and assign the new zindexval to the webcontainer I want in front. While this does appear to work, it seems extraordinarily kludgy. Is there a simpler way of doing this that I am missing?

To bring to front Button1, whatever it’s current Zindex, I do :

Button1.ZIndex = self.ControlCount+1

It would be nice to have Zindex in desktop, BTW. Talking about kludgy. Bringing to front a control in Desktop is nothing simple…

[quote=160044:@Kevin Clark]I have an application that uses several different webcontainers. When I first display one of these webcontainers, or if several webcontainers are visible and the users clicks on a webcontainer that is behind another webcontainer, I would like to bring the webcontainer with the focus to the front. The only way to control order seems to be the zindex property. There does not appear to be any “bringtofront” type method for webcontainers.

Since the frontmost webcontainer has the highest zindex, I have created a webpage-level property called zindexval that holds the highest current zindex value. When I want to bring another webcontainer to the front, I increment the webpage zindexval property and assign the new zindexval to the webcontainer I want in front. While this does appear to work, it seems extraordinarily kludgy. Is there a simpler way of doing this that I am missing?[/quote]
Just to be clear, it’s not safe to assume that your value will always be correct. Zindex values are manipulated in javascript when new pages, dialogs and containers are shown.

That’s a very good point.

Do you have a recommended method of making a WebContainer front-most?

In one of my projects I have a bunch of WebContainers swapping out, the “current” one is made visible and given a zIndex of 100 while the “old” WebContainer is given a zIndex of 0 and hidden, only one WebContainer is visible at any given time. Am I likely to get into some trouble with the web framework here?

Well, the main place you’ll have trouble is with WebDialogs. The framework looks at all of the controls (including those created with the WebSDK) and figures out how “high” it needs to display the dialog when you call Show.

It’s also worth noting that several controls can have the same zIndex technically, and in that case they’re displayed in the order they are rendered in the HTML code.

If only one webcontainer is visible at a time, do you really need to adjust the z-index?

Regarding setting the zindex based upon a webpage-based value, it seems to work at least most of the time. I have noticed it occasionally doesn’t work, but didn’t really know why. A “bringToFront” function that work reliably would be great.

On my web page I often have several webcontainers visible at once. If only one were visible, it’s true that the zindex would not matter.

When it’s looking for how high to show the WebDialog, is that through checking zIndexes or through some assumed number based on control count?

I’m already taking advantage of this fact to keep things easy for myself by using the same zIndex for all hidden WebContainers.

It might not be the case any longer, but I found that if I didn’t make sure the visible WebContainer had a higher zIndex than the invisible ones then I could not interact with the visible one. I found I had to bring the visible WebContainer frontmost via its zIndex.

This was probably exasperated by the WebContainers being full width and height.

I never had issue by using CC.ZIndex = self.ControlCount+1 but if you REALLY want to make sure to bring anything to front no matter dialogs and stuff, use something like CC.Zindex = 2000. It won’t generate any error, and unless you do have more than 2000 controls on the page, front is guaranteed.

I have about 15-20 full sized WebContainers on one page, all visible except one. There is one main toolbar and one minor above. Depending on what the user clicks I call a method that sets all WebContainers to visible = false and the desired WebContainer to visible = true. No problems so far!