3D Widget Interaction Problem

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.

+1 I’m also suffering from this problem. I can get hover interaction to work but not on-click events. Any suggestions, gentlemen?

So, I figured out that the UWidgetInteractionComponent is intended for direct pointer access to 3D menus, i.e. you point a gun or mouse cursor at a 3D menu, and it will be triggered. Mike, this is not what we’re looking for in case of the menus. We can just listen for keyboard events via template of the UMG widget, then call the base function when a mouse click is made, which is how I solved the problem. No need for UWidgetInteractionComponent in this case.

Ahh I see, well it would still be nice to know for the future in the case of peripherals such as virtual reality touch controllers, where it relies on a similar system for mouse events.

If anyone has an answer to interacting with virtual reality controllers using UWidgetInteractionComponent, I would be interested in finding out as it doesn’t seem very well-documented currently! :slight_smile: