# SComboBox Forces Window to Lose Focus

**URL:** <https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753>\
**Category:** UI\
**Tags:** unreal-engine, slate, CPP, question\
**Created:** [December 6, 2014, 7:21am UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753 "2014-12-06T07:21:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [December 6, 2014, 7:21am UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/1 "2014-12-06T07:21:29Z")

</div>

Perhaps this has been fixed in 4.6, I haven’t updated my project yet.

In 4.5.1 when I place a SComboBox in a Compound Widget at it’s root or inside an overlay or canvas the SComboBox forces the window the game is running in to lose focus when pressed. If the game is full screen it kicks it out of full screen.

Header  
#pragma once

```
#include "Slate.h"
#include "TestBoxWidget.generated.h"

USTRUCT()
struct FWorkDamnit
{
	GENERATED_USTRUCT_BODY()

	FString Derp;
};

class STestBoxWidget : public SCompoundWidget
{
	SLATE_BEGIN_ARGS(STestBoxWidget)
	{

	}
	SLATE_END_ARGS()

public:
	void Construct(const FArguments& args);

	TArray<TSharedPtr<FWorkDamnit>> Data;
};

```

Source

```
#include "GameFrameworks3_Wk3.h"
#include "TestBoxWidget.h"

void STestBoxWidget::Construct(const FArguments& args)
{
	Data.Add(MakeShareable(new FWorkDamnit()));
	Data.Add(MakeShareable(new FWorkDamnit()));
	Data.Add(MakeShareable(new FWorkDamnit()));

	ChildSlot
		[
			SNew(SCanvas)
			+ SCanvas::Slot()
			.Size(FVector2D(300, 100))
			.Position(FVector2D(50, 50))
			[
				SNew(SComboBox<TSharedPtr<FWorkDamnit>>)
				.OptionsSource(&Data)
				[
					SNew(STextBlock)
					.Text(FString("ARGH!"))
				]
			]
		];
}
```

---

<div class="post-metadata">

**Author:** ![szyszek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@szyszek](https://forums.unrealengine.com/u/szyszek)\
**Post date:** [December 7, 2014, 9:57pm UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/2 "2014-12-07T21:57:23Z")

</div>

I’ve noticed same thing in 4.5. When you call FSlateApplication::PushMenu(…) while in fullscreen mode, application will be kicked out from fullscreen.

---

<div class="post-metadata">

**Author:** ![szyszek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@szyszek](https://forums.unrealengine.com/u/szyszek)\
**Post date:** [December 16, 2014, 10:58am UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/3 "2014-12-16T10:58:05Z")

</div>

Its still in 4.6. Can we get this issue investigated please?

---

<div class="post-metadata">

**Author:** ![szyszek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@szyszek](https://forums.unrealengine.com/u/szyszek)\
**Post date:** [December 18, 2014, 3:17pm UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/4 "2014-12-18T15:17:00Z")

</div>

So I’ve done some testing myself and located the issue. It was in SlateApplication.cpp file (line 4720), comment it out and you should not experiance this problem anymore. Doing so will probably mess with Alt-tabing sequence so do it on your own responsibility ; )

```
// As we've just been activated, attempt to restore the resolution that the engine previously cached.
			// This allows us to force ourselves back to the correct resolution after alt-tabbing out of a fullscreen
			// window and then going back in again.
			Renderer->RestoreSystemResolution(ActivateEvent.GetAffectedWindow());

```

So it looks like resolution of the window is not cached after maximize operation. Whats interesting is that you wont get this problem while in editor…

Anyway, I’d love to hear official statement about it and replace this hack of mine with a proper solution ; )

---

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [December 18, 2014, 10:44pm UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/5 "2014-12-18T22:44:50Z")

</div>

Didn’t work in 4.5.1 but updating to 4.6.1 soon, will try again then.

But yes, someone from Epic commenting or giving direction would be fantastic!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 19, 2014, 6:48pm UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/6 "2014-12-19T18:48:00Z")

</div>

Hey overlawled-

I’m trying to reproduce this issue on my machine and just want to make sure I’m setting up my widget the same way you have yours. When you created your TestBoxWidget class what did you use as the parent? Let me know if there is anything else I need to match your widget setup.

Cheers

---

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [December 20, 2014, 12:12am UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/7 "2014-12-20T00:12:05Z")

</div>

Hi ,

It was added directly to the viewport.

```
if (GEngine && GEngine->GameViewport)
{
	UGameViewportClient* Viewport = GEngine->GameViewport;

	TestBox = SNew(STestBoxWidget);

	Viewport->AddViewportWidgetContent(TestBox.ToSharedRef());
}

```

---

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [January 21, 2015, 9:29pm UTC](https://forums.unrealengine.com/t/scombobox-forces-window-to-lose-focus/300753/8 "2015-01-21T21:29:51Z")

</div>

.Method(SMenuAnchor::UseCurrentWindow) was what I was missing here
