PopOver problems

I thought I’d try to replace my homegrown popovers with the new container.showPopover which look nice, but here’s the problems I found:

  1. showPopover(parentControl) requires a desktopUIControl as its parentControl. So can’t use it based on a container or window. Adding a new control on-the-fly doesn’t work - just crashes without error. Have to add an empty control on the window/container, position it correctly, and then use that. An overloaded showPopover(container) would be good.

  2. I wanted to add a click to a colour picker within the popped container. But opening any new window (e.g. the picker), automatically closes the popover, so can’t continue to edit in the popover.

  3. Accidental double clicking of the control to open the popover, results in duplicate popovers. Need to ensure only one is created somehow.

Note, to close the popup programmatically need self.window.close inside the container as the popover seems to be a window.

Any solutions to (2) above - otherwise I’ll revert to homegrown without the nice little pointy hat.

I’ve added an DesktopButton to the window and position it over the control where the origin of the popover should be:

'button 1 needed to have a desktop control to show the popover over
Button1.Left = cActionAdd.Left
Button1.Top = cActionAdd.Top
Button1.Width = cActionAdd.Width
Button1.Height = cActionAdd.Height
Button1.Visible = False

What are you doing to show the popover? It should hide when you click outside of the popover.

Yes, that’s the problem. It hides when the colorPicker appears.

And using your method for adding a control on the fly, crashes the app.

This is just a button I put on the container:


Yes, thanks Beatrix. A control on the container does work if not created on the fly. Just a small step I suppose. But took me a while to work out why a container couldn’t work - has to be a UIControl, not a container/window.

It took me ages to make a subclass of NSTableView with nice icons. So I understand your pain.

2 is an option with the NSPopover.

3 is either managed by using the popover behavior or using a property such as isOpen which is set to true when the popover is displayed and false when it’s closed.

there is no need to limit the number of popover shows, it is easy to control it with property. Otherwise such tricks would not be possible:

popover4x.xojo_binary_project

What does this example show? I don’t see the properties being used to control the popover, they only control the emoji position. It’s also a design I would not recommend, as closing the window will cause flicker on Windows.

Interesting example. Also highlights a small graphics bug in the top popover.

I have mentioned controlling number of popover windows with variable / property to make sure the popover was shown only once - but my example was not doing it. I did it to show that allowing to only open one popover from one object at time - by Xojo - would block other interesting use (and my example was just to show such possibility).