Close Popup View onBlur

I am making a context menu popup when the user right clicks. I am using system.perspective.openPopup to open the view where the user clicks on the screen. This works just fine.

Now I want the view to close if the user clicks any where on the screen other then this popup view. If this were a modal I could use overlayDismiss but I dont want the screen to turn black when it pops up.

Where can I put code that will tell the view to close when the user clicks any where on the page other then this popup view?

What you’re describing IS a modal, why don’t you want the darkened background ?
Do you want your popup to be movable ?

1 Like

The darkening of the background makes the website not look like an actual web application. It makes the context menu appear more like a warning or message box, which it is not. It is a menu to allow the user to select an action to perform on the item that was right clicked. No I do not want the modal to be movable.

It sounds to me that you’re application won’t have a standard web browser GUI. It means that your users will require training to use the application as the operation won’t be obvious. I wouldn’t recommend that.

Screen Shot 2022-07-23 at 8.07.52 PM

COMPONENTS have an onBlur Event, but Popups do not. If you want your popup to close when a user clicks outside the bounds, your only option is to make it a modal.

I think the darkening of the background makes it clear that an action needs to be taken, but I guess you could embed your popup view in a bigger, invisible frame that would cover the whole screen and close it when clicked.

There might also be a way to change the background color through css (potentially with an injection), if it can be selected.

I’m out my depth with CSS stuff but its selectable and changeable.

Then you should be able to change its color with a css injection:

create a style class, and in the background image property, type this:
} .modal {visibility: hidden;} {

This should hide the background frame of EVERY modal popup. If you need to target this one specifically, there are ways, but it might get a bit more trickier and I don’t have access to ignition to test it right now.
If you want to change the color, make it more transparent, or whatever, replace the visibility: hidden by whatever css property you want (google will help you on this).

Doesnt look like you’ll be able to target this specifically per popup :frowning:
I cant test it either, but i see the id:popup-ID is defined below the modal, so looks impossible to me

What I think this really needs to work properly is Mouse Events in the Session Events under Perspective. Then I could capture when the user clicks the mouse any where inside their session. When that happens a message could be sent by the Session Mouse Event onClick. Then I could setup a message handler to close the popup.

What I have done for right now is setup onClick events on the root of all my views that could be open when the context menu popup is used. The onClick event for each of these roots sends the same perspective message of mouseClicked. Then my context menu view has a handler that will receive the message if open and then close the popup.