# Slate OnMouseLeave event triggered on mouse zero coordinates

**URL:** <https://forums.unrealengine.com/t/slate-onmouseleave-event-triggered-on-mouse-zero-coordinates/416699>\
**Category:** UI\
**Tags:** unreal-engine, mouse-event, slate, mouse-position, UE4, CPP, question\
**Created:** [February 8, 2018, 2:58pm UTC](https://forums.unrealengine.com/t/slate-onmouseleave-event-triggered-on-mouse-zero-coordinates/416699 "2018-02-08T14:58:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_60aa5386](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_60aa5386](https://forums.unrealengine.com/u/anonymous_user_60aa5386)\
**Post date:** [February 8, 2018, 2:58pm UTC](https://forums.unrealengine.com/t/slate-onmouseleave-event-triggered-on-mouse-zero-coordinates/416699/1 "2018-02-08T14:58:53Z")

</div>

Hi, the problem is that **SCompoundWidget** triggering OnMouseLeave event when mouse touches top or left sides of the viewport, but still in the viewport.

Please, help me fix that.

Here is a code of widget:

**STest.h:**

```
class CLOSETHEGATE_API STest : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(STest)
	{}
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs);
	virtual void OnMouseLeave(const FPointerEvent& MouseEvent) override;
};

```

**STest.cpp:**

```
void STest::Construct(const FArguments& InArgs)
{
    ChildSlot
	.VAlign(VAlign_Fill)
	.HAlign(HAlign_Fill)
	[
		CONTENT
	];
}
void STest::OnMouseLeave(const FPointerEvent& MouseEvent)
{
	UE_LOG(LogTemp, Error, TEXT("Out of widget"));
}

```

**And somwhere in HUD created instance of the STest widget:**

```
if (GEngine)
{
	GEngine->GameViewport->AddViewportWidgetContent
	(
		SNew(SWeakWidget)
		.PossiblyNullContent(STest_VARIABLE.ToSharedRef())
	);
}
STest_VARIABLE->SetVisibility(EVisibility::Visible);

```

So, with this code, when you touches left or top sides of window you will get “Out of widget” error in log.

---

<div class="post-metadata">

**Author:** ![Repin\_Design](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/repin_design/32/598391_2.png) [@Repin\_Design](https://forums.unrealengine.com/u/Repin_Design)\
**Post date:** [June 6, 2021, 6:24pm UTC](https://forums.unrealengine.com/t/slate-onmouseleave-event-triggered-on-mouse-zero-coordinates/416699/2 "2021-06-06T18:24:46Z")

</div>

Why u set .VAlign(VAlign\_Fill).HAlign(HAlign\_Fill) at childslot? Its fill by default.
