Popup Style Controller


#1

I am trying to implement a component that will pop up when called similar to a PopOverController on iPad. Inside of this component is sliders, edit text, etc. If the user clicks outside of this component I want the view to go away. I know I can do this with popover window but I really need it to be inside of another component.

The idea is that something pops up, user edits, then clicks anywhere to get it to go away.

I have it mostly working. On creation of popup I enterModalState on the popup component and set Desktop::getInstance().addGlobalMouseListener(this);

On mouseDown I endModalState and removeGlobalListener and then hide my view. Works ok. But ultimately I would like it on mouseUp instead of mouseDown but while in a modal state the mouseUp events never get called. The reason for wanting the mouseUP is because the mouseUp event gets passed to whatever component the user clicked on outside of my popup component and really I want the event to be ‘eaten’.

Am I making this more complicated than it should be? This approach is quite elegant and works inside of the component without any real hacks to listen to other mouse events. But that mouseUP call is killing me :slight_smile:


#2

Isn’t that a CallOutBox?


#3

In general/theory it works. But it does not eat the up event afterwards. And it really causes strange issues if the user clicks down on a slider (not the thumb) while the calloutbox is open (among a few other things). The slider jumps to the location, never sends a changed event, and never removes the bubble value box that is attached to the slider.

I have followed the workflow and unfortunately the modal events stop the mouseUp from ever happening. Ideally closing the calloutbox (or my custom one) should happen on the mouseUp event rather than the mouse down. This way there are no more mouse events to worry about, the box closes and nothing happens elsewhere (this is how a Popover works on iPad or 10.8 in Mac SDK). But with the way the internalMouseDown currently works it calls “flags.mouseDownWasBlocked = true;” so the up event never happens. Even if it did there is nothing in internalMouseUp to call “internalModalInputAttempt”.

My attempt at using the Desktop and registering as a mouseListener was to get around this limitation and in my mouseUp I check to see if the even is part of myself or children and if not close my box. But alas…I can’t get the mouse up while in a modal this way.