I create a UMG with a webbrowser, add to viewport, I get it load url “www.baidu.com ”, and I want to input some chinese characters at textbox, but I cannot use input method, anyone hnows this issue? thanks.
my unreal version is 4.15; platform is win10.
duyaokun
(duyaokun)
February 4, 2024, 4:15pm
2
/**** File UFoxWebBrowser.h ****/
#pragma once
#include "CoreMinimal.h"
#include "WebBrowser.h"
#include "FoxWebBrowser.generated.h"
/**
* My Custom Web Browser
*/
UCLASS()
class UFoxWebBrowser : public UWebBrowser
{
GENERATED_BODY()
public:
/**
* Set input method enable/disable
*/
UFUNCTION(BlueprintCallable, Category = "Web Browser")
void SetInputEnable(bool bEnable) const;
};
/**** File UFoxWebBrowser.cpp ****/
void UFoxWebBrowser ::SetInputEnable(bool bEnable) const
{
if (!WebBrowserWidget.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("WebBrowserWidget is not init."));
return;
}
if (bEnable)
{
if (ITextInputMethodSystem* const TextInputMethodSystem =
FSlateApplicationBase::Get()
.GetPlatformApplication()
->GetTextInputMethodSystem())
{
// The input method will enable to web browser
WebBrowserWidget->BindInputMethodSystem(TextInputMethodSystem);
}
}
else
{
// The input method will disable to web browser
WebBrowserWidget->UnbindInputMethodSystem();
}
}