overriding NativeOnPreviewKeyDown works but not NativeOnKeyChar

MrLloyd88
Sun, 25 Jul 2021 19:09:25 +0000
UI

Im already overriding NativeOnPreviewKeyDown which works fine.
If i try to do the same thing with NativeOnKeyChar it doesnt seem to fire.
header-

// catch keyboard presses before text input handles them
	virtual FReply NativeOnPreviewKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent) override;

	virtual FReply NativeOnKeyChar(const FGeometry& InGeometry, const FCharacterEvent& InCharEvent) override;

cpp-

FReply UCodeEditor::NativeOnPreviewKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent)
{
	//return focus to game to automatically fire off commitinputtext
	if (InKeyEvent.GetKey().ToString() == "LeftControl")
	{
		UE_LOG(LogTemp, Warning, TEXT("code editor handling left control"));
		UWidgetBlueprintLibrary::SetFocusToGameViewport();
		return FReply::Handled();
	};

	return  FReply::Unhandled();
}

FReply UCodeEditor::NativeOnKeyChar(const FGeometry& InGeometry, const FCharacterEvent& InCharEvent)
{
	UE_LOG(LogTemp, Warning, TEXT("from text input: %s"), InCharEvent.GetCharacter());

	return  FReply::Unhandled();
}

1 post - 1 participant