# Losing keyboard focus on mouse click

**URL:** <https://forums.unrealengine.com/t/losing-keyboard-focus-on-mouse-click/358660>\
**Category:** UI\
**Tags:** hud, Input, unreal-engine, UI, question, UMG\
**Created:** [May 26, 2016, 3:59pm UTC](https://forums.unrealengine.com/t/losing-keyboard-focus-on-mouse-click/358660 "2016-05-26T15:59:22Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Ciberus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ciberus/32/561261_2.png) [@Ciberus](https://forums.unrealengine.com/u/Ciberus)\
**Post date:** [February 11, 2024, 3:47pm UTC](https://forums.unrealengine.com/t/losing-keyboard-focus-on-mouse-click/358660/12 "2024-02-11T15:47:18Z")

</div>

I think its still relevant for many developers I found a solution and verified that it works in production. Hopes it will save a lot of time for somebody

> [@Common UI and Keyboard ONLY, no Mouse](https://forums.unrealengine.com/t/common-ui-and-keyboard-only-no-mouse/1234750/4):
>
> Btw in case anyone wants to support mouse also, I found a solution and verified it works in production Mostly when you click outside any widget, UI Viewport receives focus, to prevent such behavior. Create button class inherited from UCommonButtonBase with NativeOnFocusChanging // UBBaseCommonButton.cpp class BOGATYR\_API UBBaseCommonButton : public UCommonButtonBase, public IUserObjectListEntry { GENERATED\_BODY() public: #if PLATFORM\_DESKTOP || WITH\_EDITOR virtual void NativeOnFocusCh…

---

_[View the full topic](https://forums.unrealengine.com/t/losing-keyboard-focus-on-mouse-click/358660)._
