I have a 3D Widget constructed from blueprints and am wondering how to receive input from it using a BlueprintCallable function. With the 3D Widget, I have created a custom WidgetComponent and WidgetInteractionComponent, which supposedly handles input.
CMWidgetInteractionComp = CreateDefaultSubobject<UWidgetInteractionComponent>(TEXT("Interaction"));
CMWidgetInteractionComp->SetRelativeLocation(FVector(0));
CMWidgetInteractionComp->SetWorldLocation(FVector(-70, -70, 0));
CMWidgetInteractionComp->Activate(true);
CMWidgetInteractionComp->InteractionSource = EWidgetInteractionSource::Mouse;
Below is where I create the 3D Widget, which uses the widget component (CMWidget) in order to set the properties of the 3D Widget.
if (MenuPlayerController->IsLocalPlayerController()) {
if (CenterMenuClass)
{
if (!CenterMenuWidget)
{
CenterMenuWidget = CreateWidget<UCDWidget>(MenuPlayerController, CenterMenuClass.LoadSynchronous());
if (!CenterMenuWidget)
return;
CMWidget->SetActive(true);
CMWidget->SetWidget(CenterMenuWidget);
CMWidget->SetWidgetClass(CenterMenuWidget->GetClass());
CMWidget->SetVisibility(true);
FInputModeUIOnly Mode;
Mode.SetWidgetToFocus(CenterMenuWidget->GetCachedWidget());
MenuPlayerController->SetInputMode(Mode);
MenuPlayerController->bShowMouseCursor = true;
}
}
}
This WidgetInteractionComponent is an attached component to an Actor and should be able to handle mouse, keyboard, controller events, etc.
Now, I can receive input from a HangarButton when I hover a Button with my mouse, but can’t call a function when doing any other action with the button, such as clicking or pressing. I tried setting “ON Click Events” in Blueprints to be true with a player controller, but even that doesn’t work.
Has anyone else had experience with this and if so, know what the proper way to fix 3D Widgets to respond to mouse click/pressed events on buttons? I tried looking this up, but not many people seem to be using UMG and C++ to create a 3D Widget specifically.