Widget out of screen when opened with an event


I have a widget that is opening when right mouse button is clicked. However, when I click the mouse when It is close enough to viewport border (too left for example), half of widget stay out the view. How can I fix that? Thank you.

You can clamp the X and Y position from getting too close to the borders. The delay may not be necessary. Get Desired Size will only output the correct values if the widget’s size matches up with the size of the widget’s visible elements.

I know this is old and all, but what do I do when my widget returns a desired size of 0/0 ?

You can try *Force Layout Prepass *(node). And then get desired size. Is the widget on a canvas? In a container or directly in the viewport?

I just posted this on the answerhub

“The hierarchy is: I have a kind of root-widget that all other UserWidget-derived widgets are either a part of, or they get dynamically attached to and removed from a panel of it. The root-panel of everything is a canvas in this root-widget. Like I described in the original question, I was hoping I could stop my context menus from being partly off-screen when clicking near the right or bottom edge by using the panel’s “Clipping” property. They are rather small, not full screen. I don’t know how to use anchors dynamically. The only function I found related to anchors was “Set Anchors In Viewport” and I’m not sure how to use it.”

I used to have it in the viewport directly, but I moved it to the canvas to have it “clipped”, which isn’t quite working yet…

edit: I think Force Layout Prepass is actually helping. Then I will have to do it manually after all, I guess. Thanks!