# Event when a widget is "in view"?

**URL:** <https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348>\
**Category:** C++\
**Tags:** unreal-engine, Engine-Source-Code, delegates, slate, Widget, CPP, Blueprint, question\
**Created:** [February 12, 2023, 10:00pm UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348 "2023-02-12T22:00:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 12, 2023, 10:00pm UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/1 "2023-02-12T22:00:13Z")

</div>

I am looking for a delegate to process when a UWidget “enters the view” and leaves it, example:

1. When it becomes visible.
2. When it enters visible screen space by widget position or by scrolling to it.
3. On Construct, when step 1. and 2. apply.

I have been scanning the widget code, slate and the viewport but I just can’t find it. I want this for a performance optimizer I am writing. Optimally the UWidget itself must bind to such delegate to process itself.

The challenge here is that:

1. Only the UUserWidget implements a delegate for change in visibility, but it isn’t executed when added / removed / or in / out of view by geometry.
2. Construct / WidgetRebuilt executes for the entire widget tree at once, not when the widgets actually become visible by some form of navigation.

This leaves me with hundreds of widgets I could technically optimize away at any given time.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 15, 2023, 8:21am UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/2 "2023-02-15T08:21:44Z")

</div>

Bump

---

<div class="post-metadata">

**Author:** ![dagon1999](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dagon1999](https://forums.unrealengine.com/u/dagon1999)\
**Post date:** [February 15, 2023, 10:16am UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/3 "2023-02-15T10:16:44Z")

</div>

do you trying OnVisibilityChanged

> **[OnVisibilityChanged](https://docs.unrealengine.com/4.27/en-US/API/Runtime/UMG/Blueprint/UUserWidget/OnVisibilityChanged/)**
>
> Called when the visibility has changed

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 15, 2023, 11:16am UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/4 "2023-02-15T11:16:32Z")

</div>

Yes thanks for the suggestion. This event only executes on the UserWidget when you set its visibility variable. It does not reflect the actual visibility on the screen.

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [February 15, 2023, 2:22pm UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/5 "2023-02-15T14:22:03Z")

</div>

There is no such event for this, widgets will not tick unless painted, but that’s up to the parent to decide whether to paint or not.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 15, 2023, 2:27pm UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/6 "2023-02-15T14:27:26Z")

</div>

This sounds right, I’ll have to research if I can use the Paint method on the UWidget or a parent to implement something similar then

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 18, 2023, 4:14am UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/7 "2023-02-18T04:14:21Z")

</div>

Yikes, OnPaint runs like tick even when a widget has been added but not rendered yet.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [February 18, 2023, 4:24am UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/8 "2023-02-18T04:24:03Z")

</div>

Since this “tick” is running anyhow, it seems I can write a custom implementation on OnPaint.

---

<div class="post-metadata">

**Author:** ![Stearind](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Stearind](https://forums.unrealengine.com/u/Stearind)\
**Post date:** [January 25, 2024, 3:55pm UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/9 "2024-01-25T15:55:16Z")

</div>

No idea if this gonna help, but I had similar issue (using pure C++) and my widget class inherited from UUserWidget. There is a method called NativeConstruct it you are navigating by CreateWidget\<…\> it can be overrided . Or use OnNativeVisibilityChanged event when you are dealing with visibility variable.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [January 25, 2024, 6:12pm UTC](https://forums.unrealengine.com/t/event-when-a-widget-is-in-view/769348/10 "2024-01-25T18:12:41Z")

</div>

Construct runs when a widget is added or removed from a parent or viewport. OnVisibilityChanged does not reflect the actual state of the widget being visible. It might be visible but inside a list that is scrolled down to the bottom, making it invisible to the user. It might be translated off screen etc,.
