How to make floating widgets?

Yes, of course, I mentioned it already. The first -32, -32 node shifts the widget to the middle of the object. And then you apply a second offset to move it away from the edge of the screen, but only if it’s close enough to any of them. You know the size of the widget, you know the screen size of the device. It’s a bit of math time now.

Well, your widget is much larger than 32 pixels, 32 was just an example. Check in the designer how big it is and subtract half of it, or do Widget->GetDesiredSize and subtract half of that that. This will position in smack in the centre of the object.

You still need push it off the edges is some cases, precisely as you indicated in your image with the red arrows. GetViewportSize gets you the screen size, GetDesiredSize is the size of the widget.

The following is just pseudo-code, I do not know your setup but hopefully this can get you started. Essentially, if the widget position is too close to the right edge, you move it left:

You should write a separate (pure will do) function that calculates the offset. You will have 4 cases - top, bottom, left or right clipping. The above only accounts for the right clip. The values are just examples, you’d need to populate it with you own numbers and repeat it for all screen edges.

yes,but doesnt this makes ALL the widgets go the same direction? I need it like the right ones go to the left, and the left ones go to the right, same for bot and top

if I make a bigget widget it will go out of the screen doesnt matter how far I offset it

what should I put to the logic that offset the edge of the screen?

I copied what you did, and it goes out, this is when i click on the middle

aand this is when i click on the right side

Okay, I’ll figure it out from this, thanks for all your help ! :slight_smile:

Give it a go and if you still can’t figure it out, start a new thread and include your pic with arrows!