[IGN-8613] Relative positioning inside the system.perspective.openPopup scripting function

Using scripting instead of the Popup action is there a way to make a popup window in perspective open at the Bottom Right corner of the cursor click?
I can't seem to find anything on the forum about this.

I'm not sure what that means.

The manual says,

# Opens a popup view. The top left corner of the popup will be 100 pixels from the left and top edges of the session.
system.perspective.openPopup('myPopupId', 'folder/myView', position = {'left':100,'top':100})

I suspect that you could use 'bottom' and 'right' if that's what you're looking for.

@Transistor
On the popup action you can use relative positioning like the screenshot below, I want to use this functionality in the script

Fairly certain this isn't offered in scripting.

1 Like

I don't have time to check at the moment, but if you use the Popup Action as in your post #3 and run it in a browser, hit F12 for Developer Tools and see if you can find what directives the Position settings are giving. Then see if it looks like something you could include in the script position payload.

I'm 99% sure this won't work, because we manage the relative positioning based on the click event. In theory, you could write to some custom props as part of the click event, then open based on those positional values in a separate script, but I don't know if onContextMenu has access to the click position.

We do have an open ticket to add relative position properties to scripting functions, but there's a wrinkle that no one thinks about, and it's part of why we haven't done it yet: Events are almost always based off of manual interactions, but scripting functions could be invoked from anywhere at any time. Suppose someone tried to apply relative positioning to openPopup within a property change script. What would the position be relative to?

@Nicholas_Houston : As an alternative, do you need to render a View/Popup, or would a dedicated context menu solve your issue?

4 Likes

I just took the script and used the popup action for this application. The original reason I was using a script was because I had other functionality happening along with the popup, but this view doesn't require it. Thanks for the input though!