SComboBox Forces Window to Lose Focus

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!"))
				]
			]
		];
}

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

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

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 ; )

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!

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

Hi ,

It was added directly to the viewport.

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

	TestBox = SNew(STestBoxWidget);

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

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