# \[CommonUI\] Issue with SetFocus and CommonButtonBase Slate button

**URL:** <https://forums.unrealengine.com/t/commonui-issue-with-setfocus-and-commonbuttonbase-slate-button/1256399>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Widget, CPP, question\
**Created:** [August 10, 2023, 4:57am UTC](https://forums.unrealengine.com/t/commonui-issue-with-setfocus-and-commonbuttonbase-slate-button/1256399 "2023-08-10T04:57:57Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![P3Tii009](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@P3Tii009](https://forums.unrealengine.com/u/P3Tii009)\
**Post date:** [August 14, 2025, 3:29pm UTC](https://forums.unrealengine.com/t/commonui-issue-with-setfocus-and-commonbuttonbase-slate-button/1256399/5 "2025-08-14T15:29:37Z")

</div>

If anyone else runs into this issue, here’s how I worked around it. Example code is at the bottom.

We have 2 problems. The first is that `RootButton` is private inside **UCommonButtonBase**. The second is that `MyCommonButton` inside **UCommonButtonInternalBase** is `protected`. These two make it so you can’t access it directly from your own button class.

**Here is how I fixed this:**

1. **Subclass `UCommonButtonInternalBase`**

- In your subclass, create a getter function that returns `MyCommonButton`.
- This lets you safely expose it for later use.

1. **Override `ConstructInternalButton()` in your button class (which inherits from `UCommonButtonBase`)**

- This function is `protected` and `virtual`, so you can create your own subclass of **UCommonButtonInternalBase** instead of the default internal button.
- At the same time, you can cache a pointer to your custom internal button so you can use it later.

1. **Override `NativeOnFocusReceived()`**

- When your button receives focus, you can forward that focus directly to the actual Slate button (`MyCommonButton`) using the getter you exposed earlier.
- This ensures the Slate widget behaves correctly when navigating with keyboard or controller.

**This way you don’t need to touch the Common UI’s plugin code, which I really wanted to avoid.**

Here’s what that looks like in code:

**Header file:**

```auto
UCLASS()
class UCustomCommonButtonInternalBase : public UCommonButtonInternalBase
{
	GENERATED_BODY()

public:
	TSharedPtr<SCommonButton> GetSlateButton() const { return MyCommonButton; }
};

UCLASS()
class UCustomCommonButton : public UCommonButtonBase
{
	GENERATED_BODY()
	
protected:
	UPROPERTY(Transient)
	TObjectPtr<UCustomCommonButtonInternalBase> CachedInternalButton{};
	
	virtual UCommonButtonInternalBase* ConstructInternalButton() override;

	virtual FReply NativeOnFocusReceived(const FGeometry& InGeometry, const FFocusEvent& InFocusEvent) override;
};

```

**CPP file:**

```auto
UCommonButtonInternalBase* UCustomCommonButton::ConstructInternalButton()
{
	CachedInternalButton = WidgetTree->ConstructWidget<UCustomCommonButtonInternalBase>(
		UCustomCommonButtonInternalBase::StaticClass(),
		FName(TEXT("InternalRootButtonBase"))
	);
	return Cast<UCommonButtonInternalBase>(CachedInternalButton);
}

FReply UCustomCommonButton::NativeOnFocusReceived(const FGeometry& InGeometry, const FFocusEvent& InFocusEvent)
{
	Super::NativeOnFocusReceived(InGeometry, InFocusEvent);
	
	if (CachedInternalButton->GetSlateButton())
	{
		FSlateApplication::Get().SetKeyboardFocus(CachedInternalButton->GetSlateButton());
		return FReply::Handled();
	}

	return FReply::Unhandled();
}

```

---

_[View the full topic](https://forums.unrealengine.com/t/commonui-issue-with-setfocus-and-commonbuttonbase-slate-button/1256399)._
