I use event.clientX/Y in top/left keys for position arg of system.persepctive.openpopup(), so my popup open at mouse click location.
But some times the click position is near to viewport edges so my popup will display out side of the view.
I try to enable viewbound arg of system.persepctive.openpopup() and unfortunately this doesn’t work correctly when I use position arg at same time.
system.perspctive.openPopup(id, "popup/pumps", position = {"left": event.clientX,
"top": event.cleintY}, viewbound = True)
The interesting thing is if I use popup action wizard with position to relative mouse position and select viewbound it works correctly
typo or just in the copypaste?
cleintY
clientX
A couple of things to check before I definitively identify this as one of our known bugs:
- verify the aforementioned typo.
- verify you’re using the correct
viewportBound
kwarg.
If I remember correctly, this has to do with the priority we give Popup properties.
- First and foremost, we have to honor the position a user provides.
- Then we honor the dimensions.
- Then we honor the
viewportBound
setting.
But when the dimensions of the Popup do not exist we fall back to using auto
, and this sort of short-circuits the viewportBound
setting because the process can’t determine the dimensions of the view, and then omits setting some props.
This is my code:
system.perspective.openPopup(id = self.view.params.tagPath,
view = "Lib/P&ID/ABB/FI/popup",
params = {"tagPath" : self.view.params.tagPath, 'popup': True},
position = {"top": event.clientY, "left": event.clientX},
title = self.view.params.tagPath.split(']')[-1],
viewportBound = True)
So every syntax is correct.
When I use viewportBound = True it makes my popup maximize.
As you see I left the width and height of position kwarg alone so it uses the popup side.
But when I set viewportBound = Fasle, everything works correctly and user can drag the popup and bring it manually to the center.
As told earlier if I use popup wizard and use view bound it works correctly.
And as I understand viewportBound = True should only work if my popup is outside of the edge of the browser viewport. (which is not work in python But work in popup wizard)
Right, so you’re encountering two different known bugs:
- The
viewportBound
argument does not work correctly when the position arguments of a Popup result in it being drawn at or near the viewport boundary in such a way that the Popup would be forcefully opened off-screen (IGN-5138).
- Popups which have
viewportBound
set to true and which are opened partially out of bounds snap to full-screen on interaction (IGN-6119).
1 Like
You might also be interested in this older post which encountered a very similar issue, though there is no “solution” - it might just interest you.
So there is no internal ticket and it is not willing to fix it?
For me, it is not possible to work Popup Action instead and using a relative positioning approach as I do use the event.ctrlkey to open dock if user hold down ctrl key.
There are two tickets already in place to resolve the two issues you’re encountering. In calling out there was no “solution”, I only meant to clarify that the thread I was linking did not supply any solution other than waiting for the issues I specified in my previous post.
1 Like
You can probably use position {“bottom”: ,“right”:} if the clientX/Y is above a certian value than the popop will open on the other side of the pointer instead of on the bottom left
you will have to convert the event.clientX and event.clientY to be “inverse” too tho idk viewportX-clientX or something
yup this work to put the popup on the other side of the pointer
position = {"bottom": self.page.props.dimensions.viewport.height - event.clientY, "right": self.page.props.dimensions.viewport.width - event.clientX}