Editor Utility Widget - how to detect mouse click on viewport?

Hello everyone,
I’m trying to create an Editor Utility Widget in UE5.3 that allows me to spawn an actor wherever I click in the viewport.

I already have the function that returns the world space coordinates of the click location, but I don’t know how to detect when I click on the viewport to use them.

I tried to override the OnMouseButtonDown function of the Editor Utility Widget but it doesn’t fire, not sure if this event is meant to fire when you click on the viewport though.

I’m not finding anything on the web, could anyone be so kind to help me please?

Thanks in advance

3 Likes

Have spent a lot of time trying to do this without the Scriptable Tools editor mode, and haven’t come up with anything that works at Editor time, only Runtime. Just bumping this post in case anyone has a solution.

Ok there is a solution that works for me in this plugin by Houssine Mehnik:

Combining this ray with a Line Trace by Channel, I am able to return hits on any surface in the editor viewport, not runtime:

One caveat is to be careful trying to fire it whilst clicking/releasing a mouse button, as it’ll return some unexpected results in those frames/ticks. I was able to get around this by adding a short delay in Event Graph of my EUW after click release.

have you found a solution to detect the input?