WebContainer Events collide - need help and advice

Hi,

I have a WebApp with some WebContainers inside. I am a fan of popovers and I use other WebContainer to make this.

I show a popover-container on click on a button (for example) and the popover will be displayed. Now if I click next to the popover, this popover should be destroyed.

I tried it with the mouse-down/up event of the “mother”-container. But this event is also fired, if i click onto the popover (which is also a part of the “mother”-container). Result is, that the events crash, and the popover do not close.

What opportunity have I to close the popover at clicking next to it?

No ideas dudes? :frowning:

In the parent’s MouseDown, see if the spot where the user clicked is in the contained control. If it is, ignore it.

You’ve found a bug you should report though. Please make a feedback case and attach a simple example.

Sure, but how could I find out weather the Container or it’s parent was clicked?

I am not sure if this is a bug. It’s also possible, that I am incapable :slight_smile:

In Container.MouseDown, it’s the container. In parent.MouseDown, check the X and Y to see if it’s the container. Maybe had a Container.closeMe method that each would call.

Hmm, so I always have to check the mouse-position?

This could be more comfortable, if it’s included in xojo directly.

That’s why I say it’s likely a framework bug. I ran into something similar a couple months ago and just abandoned that particular UI approach. But in retrospect, seems easy enough to work around.

So,

now i check every mousedown on the mainpage. If a popover is shown and if the mouse is not in the area of the popover, i kill this popover.

Result: works one times, then not anymore.

Also if I show only a messagebox instead of removing the popover.

This is surely a bug. What other opportunity do I have? There’re appointments of me in this project. I can’t really wait until XOJO fix it. Or am I incapable?

You might need to back up and consider a different UI design. It happens occasionally with Web Edition because of some bug or some limitation in how events flow.

That said, I actually did get something like this to work. The MouseDown event flow was a challenge. Here is what I did:

• The “popover” is a WebContainer. In design mode, I hid its instance blow the visible page. I gave it “Show” and “Hide” methods to position itself correctly in the parent, with location passed as parameter to the Show method.

• In the parent, I have a property that keeps track of the active popover.

• In parent’s MouseDown, I hide the active popover, if there is one.

• For each control in the parent, in its MouseDown, I hide the active popover, if there is one. My parent WebPage did not have a lot of controls, just a few containers (which contained lots of controls). So this was easy. If you have lots of control on the parent, this might be a pain.

I have on the mainpage only 4 Containers. Most of them are empty first and will be filled over code.
But I have ca. 20 different popover-container.

If I understand you correctly, I have to add each popover to the mainpage, invisible, and I fill them if needed with the datas.

At the moment I add instances of the container if needed.

I don’t think that this is a performant way. But I also don’t have a better solution.

Grmbl…

You could dynamically instantiate the popovers too. They’re going to pop up a little faster if they’re already on the client side. Of course, if you have a whole bunch of different ones, initial page load may be slower. Basically, it’s a trade-off, but either should work.

no I can not instantiate the popovers if they’re a part of a webpage.

I tried it so:

Dim C as new Mainpage.Popover1

Oh man, crazy that I’m hanging on such a simple thing…

That’s not how you dynamically instantiate a container. I don’t have the user guide open, but it’s described in there. Search for EmbedWithin.

I got the solution:
ever when I add a popover, I add a webcontainer bevor, which opacity = 0. So the container is not visible. And on MouseUpEvent I only do close the container and the popover.

easy and performant.