# Detect if mouse is over any UMG elements

**URL:** <https://forums.unrealengine.com/t/detect-if-mouse-is-over-any-umg-elements/428843>\
**Category:** UI\
**Tags:** raycasting, unreal-engine, UI, CPP, question, UMG\
**Created:** [July 6, 2018, 8:05pm UTC](https://forums.unrealengine.com/t/detect-if-mouse-is-over-any-umg-elements/428843 "2018-07-06T20:05:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byg\_ben](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@byg\_ben](https://forums.unrealengine.com/u/byg_ben)\
**Post date:** [July 6, 2018, 8:05pm UTC](https://forums.unrealengine.com/t/detect-if-mouse-is-over-any-umg-elements/428843/1 "2018-07-06T20:05:39Z")

</div>

I’m currently highlighting things in the world by doing a raycast using `GetActorByChannelAtScreenPoint`.

However I’d like to skip this any time the mouse is over any UMG elements.

Is there a way to detect this?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [July 6, 2018, 11:17pm UTC](https://forums.unrealengine.com/t/detect-if-mouse-is-over-any-umg-elements/428843/2 "2018-07-06T23:17:22Z")

</div>

AActor is already have code to detect mouse hovers and clicks and had delegates you can use

> **[OnBeginCursorOver](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/GameFramework/AActor/OnBeginCursorOver/)**
>
> Called when the mouse cursor is moved over this actor if mouse over events are enabled in the player controller.

> **[OnEndCursorOver](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/GameFramework/AActor/OnEndCursorOver/)**
>
> Called when the mouse cursor is moved off this actor if mouse over events are enabled in the player controller.

> **[OnClicked](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/GameFramework/AActor/OnClicked/)**
>
> Called when the left mouse button is clicked while the mouse is over this actor and click events are enabled in the player controller.

> **[OnReleased](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/GameFramework/AActor/OnReleased/)**
>
> Called when the left mouse button is released while the mouse is over this actor and click events are enabled in the player controller.

They puts UI in to account, you also need to set bEnableMouseOverEvents to true in player controller, this able line tracing so set it to false when you don’t need it
