I'm trying to "anchor" a widget to the side of the screen. However, I only want to do this on demand, since this will be a moveable window (which I sometimes want to reset back to its anchored position). Is there a method that already does this?
I found UIAnchor, but that uses the widget's anchor point, so I have to compensate for it using offsets. Also, once I drag the window somewhere else, the anchor no longer works properly when I re-activate it (since its transform has changed; I have to reset both the anchor's and widget's position for it to work again).
What I would love to have is a method that will move a widget to the specified edge/corner, while also taking into account the widget's bounds instead of its anchor point. For instance, if I move it to the bottom left of the screen, the bottom left corner of the widget should touch the bottom left of the screen. Like-wise, if I move it to the top right of the screen, the top right of the widget should touch the top right of the screen. Currently, if the widget's anchor point is at the top left, then moving it to the bottom right of the screen would move it's top left point to the bottom right of the screen (i.e. it moves off of the screen).
This seems like a common use case, so I'm hoping this functionality already exists.