UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SWebBrowserView.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
7#include "Widgets/SWidget.h"
11#include "Widgets/SViewport.h"
13
23
28DECLARE_DELEGATE_FourParams(FOnConsoleMessageDelegate, const FString& /*Message*/, const FString& /*Source*/, int32 /*Line*/, EWebBrowserConsoleLogSeverity /*Severity*/);
30
31#if WITH_CEF3 || PLATFORM_APPLE
33#else
35#endif
36
38 : public SCompoundWidget
39{
40public:
41 DECLARE_DELEGATE_RetVal_TwoParams(bool, FOnBeforeBrowse, const FString& /*Url*/, const FWebNavigationRequest& /*Request*/)
42 DECLARE_DELEGATE_RetVal_ThreeParams(bool, FOnLoadUrl, const FString& /*Method*/, const FString& /*Url*/, FString& /* Response */)
49
50
64
67
68
69 SLATE_ARGUMENT(FString, InitialURL)
70
71
72 SLATE_ARGUMENT(TOptional<FString>, ContentsToLoad)
73
74
76
77
79
80
82
83
85
86
87 SLATE_ARGUMENT(FColor, BackgroundColor)
88
89
90 SLATE_ARGUMENT(int, BrowserFrameRate)
91
92
94
95
97
98
99 SLATE_ARGUMENT(TArray<FString>, AltRetryDomains)
100
101
103
105 SLATE_EVENT(FSimpleDelegate, OnLoadCompleted)
106
108 SLATE_EVENT(FSimpleDelegate, OnLoadError)
109
111 SLATE_EVENT(FSimpleDelegate, OnLoadStarted)
112
114 SLATE_EVENT(FOnTextChanged, OnTitleChanged)
115
117 SLATE_EVENT(FOnTextChanged, OnUrlChanged)
118
120 SLATE_EVENT(FOnBeforePopupDelegate, OnBeforePopup)
121
123 SLATE_EVENT(FOnCreateWindowDelegate, OnCreateWindow)
124
126 SLATE_EVENT(FOnCloseWindowDelegate, OnCloseWindow)
127
129 SLATE_EVENT(FOnFloatingCloseButtonPressedDelegate, OnFloatingCloseButtonPressed)
130
132 SLATE_EVENT(FOnBeforeBrowse, OnBeforeNavigation)
133
135 SLATE_EVENT(FOnLoadUrl, OnLoadUrl)
136
138 SLATE_EVENT(FOnShowDialog, OnShowDialog)
139
141 SLATE_EVENT(FSimpleDelegate, OnDismissAllDialogs)
142
144 SLATE_EVENT(FOnSuppressContextMenu, OnSuppressContextMenu);
145
147 SLATE_EVENT(FOnCreateToolTip, OnCreateToolTip)
148
150 SLATE_EVENT(FOnDragWindow, OnDragWindow)
151
153 SLATE_EVENT(FOnUnhandledKeyDown, OnUnhandledKeyDown)
154
156 SLATE_EVENT(FOnUnhandledKeyUp, OnUnhandledKeyUp)
157
159 SLATE_EVENT(FOnUnhandledKeyChar, OnUnhandledKeyChar)
160
162 SLATE_EVENT(FOnConsoleMessageDelegate, OnConsoleMessage)
163
165
166
169
171
172 virtual bool SupportsKeyboardFocus() const override {return true;}
173
174 virtual FReply OnFocusReceived(const FGeometry& MyGeometry, const FFocusEvent& InFocusEvent) override;
175
181 WEBBROWSER_API void Construct(const FArguments& InArgs, const TSharedPtr<IWebBrowserWindow>& InWebBrowserWindow = nullptr);
182
183 WEBBROWSER_API virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
184
190 WEBBROWSER_API void LoadURL(FString NewURL);
191
198 WEBBROWSER_API void LoadString(FString Contents, FString DummyURL);
199
201 WEBBROWSER_API void Reload();
202
205
208
214 WEBBROWSER_API FString GetUrl() const;
215
222
224 WEBBROWSER_API bool IsLoaded() const;
225
227 WEBBROWSER_API bool IsLoading() const;
228
230 WEBBROWSER_API bool IsInitialized() const;
231
233 WEBBROWSER_API void ExecuteJavascript(const FString& ScriptText);
234
242 WEBBROWSER_API void GetSource(TFunction<void (const FString&)> Callback) const ;
243
253 WEBBROWSER_API void BindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true);
254
262 WEBBROWSER_API void UnbindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true);
263
265
267
269
271
273 WEBBROWSER_API bool CanGoBack() const;
274
276 WEBBROWSER_API void GoBack();
277
279 WEBBROWSER_API bool CanGoForward() const;
280
283
286
290
295
298
301
302private:
303
304 WEBBROWSER_API void SetupParentWindowHandlers();
305
307 WEBBROWSER_API void HandleBrowserWindowDocumentStateChanged(EWebBrowserDocumentState NewState);
308
310 WEBBROWSER_API void HandleBrowserWindowNeedsRedraw();
311
313 WEBBROWSER_API void HandleTitleChanged(FString NewTitle);
314
316 WEBBROWSER_API void HandleUrlChanged(FString NewUrl);
317
319 WEBBROWSER_API void HandleToolTip(FString ToolTipText);
320
326 WEBBROWSER_API bool HandleBeforeNavigation(const FString& Url, const FWebNavigationRequest& Request);
327
328 WEBBROWSER_API bool HandleLoadUrl(const FString& Method, const FString& Url, FString& OutResponse);
329
336
342 WEBBROWSER_API bool HandleCloseWindow(const TWeakPtr<IWebBrowserWindow>& BrowserWindow);
343
345 WEBBROWSER_API void HandleFloatingCloseButtonPressed();
346
349
351 WEBBROWSER_API void HandleDismissAllDialogs();
352
354 WEBBROWSER_API bool HandleBeforePopup(FString URL, FString Target);
355
357 WEBBROWSER_API void HandleShowPopup(const FIntRect& PopupSize);
358
360 WEBBROWSER_API void HandleDismissPopup();
361
363 WEBBROWSER_API void HandleMenuDismissed(TSharedRef<IMenu>);
364
365 virtual FPopupMethodReply OnQueryPopupMethod() const override
366 {
367 return PopupMenuMethod.IsSet()
368 ? FPopupMethodReply::UseMethod(PopupMenuMethod.GetValue())
370 }
371
372 WEBBROWSER_API void HandleWindowDeactivated();
373 WEBBROWSER_API void HandleWindowActivated();
374 WEBBROWSER_API bool UnhandledKeyDown(const FKeyEvent& KeyEvent);
375 WEBBROWSER_API bool UnhandledKeyUp(const FKeyEvent& KeyEvent);
376 WEBBROWSER_API bool UnhandledKeyChar(const FCharacterEvent& CharacterEvent);
377
378 WEBBROWSER_API bool HandleDrag(const FPointerEvent& MouseEvent);
379 WEBBROWSER_API void HandleConsoleMessage(const FString& Message, const FString& Source, int32 Line, EWebBrowserConsoleLogSeverity Serverity);
380
381 WEBBROWSER_API TOptional<FSlateRenderTransform> GetPopupRenderTransform() const;
382private:
383
385 TSharedPtr<IWebBrowserWindow> BrowserWindow;
387 mutable TWeakPtr<SWindow> SlateParentWindowPtr;
389 TSharedPtr<FWebBrowserViewport> BrowserViewport;
393 TSharedPtr<SWebBrowserWidget> BrowserWidget;
394
396
401 TWeakPtr<IMenu> PopupMenuPtr;
402
404 TOptional<EPopupMethod> PopupMenuMethod;
405
407 FText AddressBarUrl;
408
410 FSimpleDelegate OnLoadCompleted;
411
413 FSimpleDelegate OnLoadError;
414
416 FSimpleDelegate OnLoadStarted;
417
419 FOnTextChanged OnTitleChanged;
420
422 FOnTextChanged OnUrlChanged;
423
425 FOnBeforePopupDelegate OnBeforePopup;
426
428 FOnCreateWindowDelegate OnCreateWindow;
429
431 FOnCloseWindowDelegate OnCloseWindow;
432
434 FOnFloatingCloseButtonPressedDelegate OnFloatingCloseButtonPressed;
435
437 FOnBeforeBrowse OnBeforeNavigation;
438
440 FOnLoadUrl OnLoadUrl;
441
443 FOnShowDialog OnShowDialog;
444
446 FSimpleDelegate OnDismissAllDialogs;
447
448 FOnSuppressContextMenu OnSuppressContextMenu;
449
451 FOnCreateToolTip OnCreateToolTip;
452
454 FOnDragWindow OnDragWindow;
455
457 FOnUnhandledKeyDown OnUnhandledKeyDown;
458
460 FOnUnhandledKeyUp OnUnhandledKeyUp;
461
463 FOnUnhandledKeyChar OnUnhandledKeyChar;
464
466 FOnConsoleMessageDelegate OnConsoleMessage;
467
468protected:
470
471};
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define SLATE_ATTRIBUTE(AttrType, AttrName)
Definition DeclarativeSyntaxSupport.h:192
#define SLATE_BEGIN_ARGS(InWidgetType)
Definition DeclarativeSyntaxSupport.h:63
#define SLATE_EVENT(DelegateName, EventName)
Definition DeclarativeSyntaxSupport.h:458
#define SLATE_END_ARGS()
Definition DeclarativeSyntaxSupport.h:116
#define SLATE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:208
#define DECLARE_DELEGATE_RetVal_OneParam(ReturnValueType, DelegateName, Param1Type)
Definition DelegateCombinations.h:54
#define DECLARE_DELEGATE_RetVal(ReturnValueType, DelegateName)
Definition DelegateCombinations.h:41
#define DECLARE_DELEGATE(DelegateName)
Definition DelegateCombinations.h:20
#define DECLARE_DELEGATE_RetVal_TwoParams(ReturnValueType, DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:63
#define DECLARE_DELEGATE_FourParams(DelegateName, Param1Type, Param2Type, Param3Type, Param4Type)
Definition DelegateCombinations.h:75
#define DECLARE_DELEGATE_RetVal_ThreeParams(ReturnValueType, DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:72
return true
Definition ExternalRpcRegistry.cpp:601
EWebBrowserDialogEventResponse
Definition IWebBrowserDialog.h:27
EWebBrowserDocumentState
Definition IWebBrowserWindow.h:18
EWebBrowserConsoleLogSeverity
Definition IWebBrowserWindow.h:26
EPopupMethod
Definition PopupMethodReply.h:9
SWidget SWebBrowserWidget
Definition SWebBrowserView.h:34
Definition PaintArgs.h:23
Definition PopupMethodReply.h:24
static FPopupMethodReply UseMethod(EPopupMethod WithMethod)
Definition PopupMethodReply.h:33
Definition Reply.h:24
Definition SlateRect.h:26
Definition DrawElements.h:220
Definition Text.h:385
Definition WebBrowserViewport.h:17
Definition WidgetStyle.h:15
Definition ITextInputMethodSystem.h:169
Definition IWebBrowserAdapter.h:8
Definition IWebBrowserDialog.h:42
Definition IWebBrowserPopupFeatures.h:8
Definition IWebBrowserWindow.h:85
Definition SCompoundWidget.h:22
Definition SViewport.h:31
Definition SWebBrowserView.h:39
WEBBROWSER_API bool IsLoaded() const
Definition SWebBrowserView.cpp:371
DECLARE_DELEGATE_RetVal_TwoParams(bool, FOnBeforeBrowse, const FString &, const FWebNavigationRequest &) DECLARE_DELEGATE_RetVal_ThreeParams(bool
WEBBROWSER_API void GoBack()
Definition SWebBrowserView.cpp:400
WEBBROWSER_API void Reload()
Definition SWebBrowserView.cpp:327
virtual WEBBROWSER_API int32 OnPaint(const FPaintArgs &Args, const FGeometry &AllottedGeometry, const FSlateRect &MyCullingRect, FSlateWindowElementList &OutDrawElements, int32 LayerId, const FWidgetStyle &InWidgetStyle, bool bParentEnabled) const override
Definition SWebBrowserView.cpp:243
WEBBROWSER_API void CloseBrowser()
Definition SWebBrowserView.cpp:507
WEBBROWSER_API void UnbindInputMethodSystem()
Definition SWebBrowserView.cpp:669
WEBBROWSER_API bool CanGoForward() const
Definition SWebBrowserView.cpp:408
WEBBROWSER_API void SetBrowserKeyboardFocus()
Definition SWebBrowserView.cpp:801
WEBBROWSER_API bool HandleSuppressContextMenu()
Definition SWebBrowserView.cpp:746
WEBBROWSER_API void ExecuteJavascript(const FString &ScriptText)
Definition SWebBrowserView.cpp:584
WEBBROWSER_API void GoForward()
Definition SWebBrowserView.cpp:417
WEBBROWSER_API bool IsLoading() const
Definition SWebBrowserView.cpp:381
WEBBROWSER_API TSharedPtr< IWebBrowserWindow > GetBrowserWindow() const
Definition SWebBrowserView.cpp:517
virtual FReply OnFocusReceived(const FGeometry &MyGeometry, const FFocusEvent &InFocusEvent) override
Definition SWebBrowserView.cpp:278
WEBBROWSER_API FString GetUrl() const
Definition SWebBrowserView.cpp:352
FOnLoadUrl
Definition SWebBrowserView.h:42
WEBBROWSER_API bool IsInitialized() const
Definition SWebBrowserView.cpp:425
WEBBROWSER_API void UnbindAdapter(const TSharedRef< IWebBrowserAdapter > &Adapter)
Definition SWebBrowserView.cpp:652
WEBBROWSER_API void StopLoad()
Definition SWebBrowserView.cpp:335
WEBBROWSER_API void BindUObject(const FString &Name, UObject *Object, bool bIsPermanent=true)
Definition SWebBrowserView.cpp:627
WEBBROWSER_API void LoadURL(FString NewURL)
Definition SWebBrowserView.cpp:310
WEBBROWSER_API void GetSource(TFunction< void(const FString &)> Callback) const
Definition SWebBrowserView.cpp:592
WEBBROWSER_API void LoadString(FString Contents, FString DummyURL)
Definition SWebBrowserView.cpp:319
WEBBROWSER_API void BindInputMethodSystem(ITextInputMethodSystem *TextInputMethodSystem)
Definition SWebBrowserView.cpp:661
WEBBROWSER_API FText GetAddressBarUrlText() const
Definition SWebBrowserView.cpp:362
WEBBROWSER_API void ShowFloatingCloseButton(bool bShow, bool bDraggable)
Definition SWebBrowserView.cpp:512
virtual bool SupportsKeyboardFocus() const override
Definition SWebBrowserView.h:172
WEBBROWSER_API void SetParentWindow(TSharedPtr< SWindow > Window)
Definition SWebBrowserView.cpp:792
WEBBROWSER_API bool CanGoBack() const
Definition SWebBrowserView.cpp:391
WEBBROWSER_API void UnbindUObject(const FString &Name, UObject *Object, bool bIsPermanent=true)
Definition SWebBrowserView.cpp:635
WEBBROWSER_API void Construct(const FArguments &InArgs, const TSharedPtr< IWebBrowserWindow > &InWebBrowserWindow=nullptr)
Definition SWebBrowserView.cpp:83
WEBBROWSER_API FText GetTitleText() const
Definition SWebBrowserView.cpp:343
WEBBROWSER_API void BindAdapter(const TSharedRef< IWebBrowserAdapter > &Adapter)
Definition SWebBrowserView.cpp:643
Definition SWidget.h:165
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition SharedPointer.h:1295
Definition Object.h:95
@ false
Definition radaudio_common.h:23
Definition Events.h:606
Definition Color.h:486
Definition Events.h:51
Definition Geometry.h:40
Definition Events.h:431
Definition Events.h:695
Definition IWebBrowserWindow.h:73
Definition Optional.h:131
constexpr OptionalType & GetValue()
Definition Optional.h:443
constexpr bool IsSet() const
Definition Optional.h:69