Quartz UI ↗
Browse docs
On this page
Private preview · 0.57.0-devView Markdown

SQuartzUIBrowser: declaration reference

0.57.0-dev · beta source documentation. Native, Blueprint, Editor and rendering examples are source-reviewed, not executed in Unreal during this scan. See validation and limits.

Pinned source (source: Source/QuartzUIRuntime/Public/SQuartzUIBrowser.h) · integration recipe · practical guide

SQuartzUIBrowser

Advanced type. Thin public Slate boundary around Epic's WebBrowser module. Keeping this wrapper small lets a future backend replace Chromium without changing game UI code.

Prerequisites / integration: Exact local player and configured app; Slate/UMG dependencies for native presentation work. Use the SQuartzUIBrowser recipe in the host module QuartzUIRuntime.

Minimal example / lifecycle: Embed in native Slate with exact OwningLocalPlayer and app policy. Slate wrapper owns browser/text-input binding and bridge.

Avoid: Scaling a low-resolution raster or bypassing lifetime with raw CEF access. Match the exact declaration below; dependent DTOs/enums are values used by this owner, not independent systems.

Exact source line (source: Source/QuartzUIRuntime/Public/SQuartzUIBrowser.h#L22)

Complete header

Source snapshot, not an additional example. Unreal annotations distinguish exposed Blueprint nodes from native-only/private methods.

#pragma once

#include "CoreMinimal.h"
#include "IWebBrowserSingleton.h"
#include "SWebBrowserView.h"
#include "UObject/StrongObjectPtr.h"
#include "QuartzUIBridge.h"
#include "QuartzUICoreContract.h"
#include "QuartzUIDiagnostics.h"
#include "QuartzUILoadRecovery.h"
#include "QuartzUIReadiness.h"
#include "QuartzUISceneBackdrop.h"
#include "Widgets/SCompoundWidget.h"

class ULocalPlayer;
class FQuartzUIFrameProbe;

/**
 * Thin public Slate boundary around Epic's WebBrowser module.
 * Keeping this wrapper small lets a future backend replace Chromium without changing game UI code.
 */
class QUARTZUIRUNTIME_API SQuartzUIBrowser final : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(SQuartzUIBrowser)
		: _InitialUrl(TEXT("about:blank"))
		, _InitialHtml()
		, _SupportsTransparency(true)
		, _BrowserFrameRate(60)
		, _AllowTextSelection(false)
		, _EnableSceneBackdrop(true)
		, _OwningLocalPlayer(nullptr)
		, _ShowLoadRecoveryUI(true)
		, _MaxLoadRecoveryAttempts(FQuartzUILoadRecoveryPolicy::DefaultMaxAttempts)
		, _HandshakeTimeoutSeconds(FQuartzUIReadinessPolicy::DefaultHandshakeTimeoutSeconds)
		, _ContractHash(FQuartzUICoreContract::GetContractHash())
		, _ContextSettings()
	{
	}

		SLATE_ARGUMENT(FString, InitialUrl)
		SLATE_ARGUMENT(FString, InitialHtml)
		/** Exact packaged origin owned by this browser view. */
		SLATE_ARGUMENT(FString, AllowedPackagedOrigin)
#if WITH_EDITOR
		/** Exact loopback origin activated by the Editor-owned development server. */
		SLATE_ARGUMENT(FString, AllowedDevelopmentOrigin)
#endif
		SLATE_ARGUMENT(bool, SupportsTransparency)
		SLATE_ARGUMENT(int32, BrowserFrameRate)
		/** Game UI defaults to non-selectable document text. Form controls remain editable. */
		SLATE_ARGUMENT(bool, AllowTextSelection)
		/** Enables native filtering for elements marked with data-quartzui-backdrop. */
		SLATE_ARGUMENT(bool, EnableSceneBackdrop)
		SLATE_ARGUMENT(ULocalPlayer*, OwningLocalPlayer)
		/** False keeps optional passive views transparent when loading fails. */
		SLATE_ARGUMENT(bool, ShowLoadRecoveryUI)
		/** Manual retry budget. Zero disables retry while retaining the native failure UI. */
		SLATE_ARGUMENT(int32, MaxLoadRecoveryAttempts)
		/** Bounded post-load wait for the generated JavaScript/native contract handshake. */
		SLATE_ARGUMENT(float, HandshakeTimeoutSeconds)
		/** Exact generated contract identity for this app/view. */
		SLATE_ARGUMENT(FString, ContractHash)
		/** Optional isolated CEF request context; an empty cache path remains memory-only. */
		SLATE_ARGUMENT(TOptional<FBrowserContextSettings>, ContextSettings)
		SLATE_EVENT(FSimpleDelegate, OnLoadStarted)
		SLATE_EVENT(FSimpleDelegate, OnLoadCompleted)
		/** Fires once per document after load and matching contract handshake. */
		SLATE_EVENT(FSimpleDelegate, OnReady)
		/** Fires once per document when its readiness handshake fails or times out. */
		SLATE_EVENT(FOnTextChanged, OnReadyError)
		SLATE_EVENT(FSimpleDelegate, OnLoadError)
		SLATE_EVENT(FSimpleDelegate, OnLoadRecovered)
		SLATE_EVENT(FSimpleDelegate, OnLoadRecoveryExhausted)
		SLATE_EVENT(FOnTextChanged, OnTitleChanged)
		SLATE_EVENT(FOnTextChanged, OnUrlChanged)
		SLATE_EVENT(FOnTextChanged, OnNavigationBlocked)
		SLATE_EVENT(FOnConsoleMessageDelegate, OnConsoleMessage)
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs);
	virtual ~SQuartzUIBrowser() override;

	virtual void Tick(const FGeometry& AllottedGeometry, double InCurrentTime, float InDeltaTime) override;
	virtual int32 OnPaint(
		const FPaintArgs& Args,
		const FGeometry& AllottedGeometry,
		const FSlateRect& MyCullingRect,
		FSlateWindowElementList& OutDrawElements,
		int32 LayerId,
		const FWidgetStyle& InWidgetStyle,
		bool bParentEnabled) const override;
	virtual FReply OnPreviewKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override;

	bool LoadUrl(const FString& Url);
	bool LoadHtml(const FString& Html, const FString& DummyUrl = TEXT("about:blank"));
	void Reload();
	/** Retries only a failed load and never exceeds the configured attempt budget. */
	bool RetryFailedLoad();
	void ExecuteJavaScript(const FString& Script);
	void SetAllowTextSelection(bool bAllow);
	void SetSceneBackdropEnabled(bool bEnabled);
	/** Uses Epic's public browser-window disable path to stop hidden-view updates. */
	bool SetRuntimeSuspended(bool bSuspended);
	/** Clears Chromium's pressed/capture state when native layer ownership moves away. */
	bool CancelInputCapture();

	FText GetTitleText() const;
	FString GetUrl() const;
	bool IsLoaded() const;
	bool IsReady() const { return ReadinessGate.IsReady(); }
	bool IsTextSelectionAllowed() const { return bAllowTextSelection; }
	bool IsSceneBackdropEnabled() const { return bEnableSceneBackdrop; }
	bool IsRuntimeSuspended() const { return bRuntimeSuspended; }
	EQuartzUILoadRecoveryState GetLoadRecoveryState() const { return LoadRecoveryState; }
	int32 GetConsecutiveLoadRecoveryAttempts() const { return ConsecutiveLoadRecoveryAttempts; }
	int32 GetMaxLoadRecoveryAttempts() const { return MaxLoadRecoveryAttempts; }
	float GetHandshakeTimeoutSeconds() const { return HandshakeTimeoutSeconds; }
	bool IsLoadRecoveryVisible() const
	{
		return bShowLoadRecoveryUI
			&& LoadRecoveryState != EQuartzUILoadRecoveryState::Healthy;
	}
	/** True after this view binds UE's platform text-input system to Epic's browser. */
	bool IsInputMethodSystemBound() const { return bInputMethodSystemBound; }
	FQuartzUIViewStats GetDiagnostics() const;
	UQuartzUIBridge* GetBridge() const { return Bridge.Get(); }
	/** Opt-in mixed viewport UI: normalized document rectangles own pointer input. Empty means passive. */
	bool SetPointerInputRegions(const TArray<FBox2D>& Regions);
	bool IsPointerOverInputRegion() const;
	virtual FReply OnMouseButtonDown(const FGeometry& Geometry, const FPointerEvent& Event) override;
	virtual FReply OnMouseButtonUp(const FGeometry& Geometry, const FPointerEvent& Event) override;
	virtual FReply OnMouseButtonDoubleClick(const FGeometry& Geometry, const FPointerEvent& Event) override;
	virtual FReply OnMouseMove(const FGeometry& Geometry, const FPointerEvent& Event) override;
	virtual FReply OnMouseWheel(const FGeometry& Geometry, const FPointerEvent& Event) override;
	virtual void OnMouseLeave(const FPointerEvent& Event) override;
	/** Exact inner widget that owns Chromium keyboard focus and IME. */
	TSharedPtr<SWidget> GetFocusableWidget() const;

private:
	TSharedPtr<FQuartzUIFrameProbe> FrameProbe;
	TWeakObjectPtr<ULocalPlayer> SceneBackdropPlayer;
	bool ContainsPointer(const FGeometry& Geometry, const FVector2D& ScreenPosition) const;
	TArray<FBox2D> PointerInputRegions;
	bool bUsePointerInputRegions = false;
	bool bPointerWasInside = false;
	void ApplyPagePolicy();
	void HandleLoadStarted();
	void HandleLoadCompleted();
	void HandleLoadError();
	void HandleClientReady();
	void HandleClientReadyFailure(const FString& ErrorCode);
	void HandleReadinessFailure(const FString& ErrorCode);
	void TryNotifyReady(bool bBecameReady);
	bool HandleBeforeNavigation(const FString& Url, const FWebNavigationRequest& Request);
	bool HandleBeforePopup(FString Url, FString Frame);
	bool BlockNavigation(const FString& Url, bool bPopup, bool bMainFrame);
	void HandleOutboundMessage(const FString& EnvelopeJson);
	void BindInputMethodSystem();
	void UnbindInputMethodSystem();
	void StartLoadTimer();
	double FinishLoadTimer();
	void ResetLoadRecoveryForNavigation();
	void ResetReadinessForNavigation();
	EVisibility GetLoadRecoveryVisibility() const;
	FText GetLoadRecoveryTitle() const;
	FText GetLoadRecoveryMessage() const;
	FText GetLoadRecoveryButtonText() const;
	bool CanRetryFailedLoad() const;
	FReply HandleRetryClicked();
	FQuartzUIEndpointResult HandleSceneBackdropUpdate(const FString& PayloadJson);
	FQuartzUIEndpointResult HandleAccessibilityAnnouncement(const FString& PayloadJson);

	TSharedPtr<SWebBrowserView> BrowserWidget;
	TSharedPtr<class SButton> LoadRecoveryButton;
	TStrongObjectPtr<UQuartzUIBridge> Bridge;
	FSimpleDelegate OnLoadStarted;
	FSimpleDelegate OnLoadCompleted;
	FSimpleDelegate OnReady;
	FOnTextChanged OnReadyError;
	FSimpleDelegate OnLoadError;
	FSimpleDelegate OnLoadRecovered;
	FSimpleDelegate OnLoadRecoveryExhausted;
	FOnTextChanged OnNavigationBlocked;
	FQuartzUIViewStats ViewStats;
	double LoadStartedAtSeconds = 0.0;
	bool bHasActiveLoadTimer = false;
	bool bAllowTextSelection = false;
	bool bEnableSceneBackdrop = true;
	bool bShowLoadRecoveryUI = true;
	bool bRuntimeSuspended = false;
	bool bInputMethodSystemBound = false;
	EQuartzUILoadRecoveryState LoadRecoveryState = EQuartzUILoadRecoveryState::Healthy;
	int32 ConsecutiveLoadRecoveryAttempts = 0;
	int32 MaxLoadRecoveryAttempts = FQuartzUILoadRecoveryPolicy::DefaultMaxAttempts;
	float HandshakeTimeoutSeconds = FQuartzUIReadinessPolicy::DefaultHandshakeTimeoutSeconds;
	FQuartzUIHandshakeTimer HandshakeTimer;
	FString ReadinessFailureReason;
	FQuartzUISceneBackdropSnapshot SceneBackdropSnapshot;
	FQuartzUIReadinessGate ReadinessGate;
	double LastAccessibleAnnouncementSeconds = -1.0;
	FDelegateHandle InputMethodSystemSlatePreShutdownDelegateHandle;
};