Get mouse click location relative to widget local space

Hi,

I’m trying to find out mouse click location on widget but relative to the widget, not the viewport. Usually I would take the viewport click location, subtract the widget location and that would work, but with Canvas Panel I’m struggling to find the viewport location of the widget. There is the Slot as Canvas SlotGet Position but this gives me the widget location relative to the Canvas Panel Anchor, it works when it’s anchored to top left corner, but not if for example anchored to bottom right.

So two questions:

  • Is there a way to get viewport location of a widget that is part of canvas panel?
  • Is there any other way to get click location withing widget space

Regards,

1 Like

Looks like the answer was rather simple. I was overwriting the widget “OnMouseButtonDown” so it got the Geometry of the canvas panel which was equal to the viewport. Instead, I should have get the mouse event on a border around my overlay and just set it up like:

97868-screenshot_20160710_000601.png

Works like a charm.

2 Likes