I tried to test this by creating a project in 4.8.3 and converting it to 4.9. I first created a new class based on actor and setup a static mesh component in the constructor:
After compiling I created a blueprint and set a static mesh to the component. This worked to print the “Hovering” message when I moused over the static mesh in both 4.8.3 and 4.9. Could you let me know if this is similar to how your function is setup or if you used another method.
AMyActor::AMyActor(const FObjectInitializer& OI)
:Super(OI)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
OnBeginCursorOver.AddDynamic(this, &AMyActor::OnHover);
}
I then added a static mesh in the blueprint and when hovering over the blueprint in game the Hovering message appeared as expected. Could you send me your project so I can test what you’re seeing directly?
The video did not play properly (I have the audio but the video is completely fragmented). The OnBeginCursorOver.AddDynamic() method has worked properly for me in the tests that I’ve run. If your project is too large to upload then could you reproduce the issue in a new project and send that instead?
added a hovering function at the level of the character (HighlightOn function), which doesn’t work on my computer
tried to add a hovering function on an extra static mesh component, but the component won’t show in game !!! (though it shows in the BP, and HiddenInGame is false, so another mystery for me).
so i tried to define the binding on the capsule, but that didn’t trigger the function
In short, none of my tries could trigger any of the two bound functions i defined.
Can you try this project and if yes, do you have the same behavior on your computer ?
I was able to test the project you uploaded. You’re correct that the mouse over event is not triggering however this only appears to be on a character. This has been reported (UE-20801) for investigation.
Huuh… so anyone else is experiencing that problem too.
Already uploaded a Bug report about it, but was closed:
For me, the same thing happens on a class derived from AActor. Worked like a charm in 4.8.
Perhaps worth to note is that I had to derive a player controller (in 4.8) to get mouse events going according to this tutorial:
If this might not be necessary anymore in 4.9, perhaps this might be the root cause? Only an idea.
Please fix it. You would make an old man very happy!
Have a nice weekend!
Interestingly enough, it can work. In the following project (it’s an update from the previous same link) i have set up an actor derived class to be hovered.
If you try this project, you’ll see that the hovering doesn’t work for the character (as recognized by ), but it works for the actor (the cube beside the character).
Now where it becomes really interesting is that the exact same code doesn’t work when copy pasted from this toy project to my migrated project.
So i guess there must be some sort of interaction (with UI or or i don’t know what) that breaks the mouse event in the full project.
So in principle, by adding elements one by one from my project to the toy project, at one point i should be able to break the hovering on the actor and single out the source of the problem.
When i block the execution of Viewport->AddViewportWidgetContent by adding a comment to the line, the hovering is back and ok.
void AYagHUD::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (GEngine && GEngine->GameViewport)
{
// get viewport
UGameViewportClient* Viewport = GEngine->GameViewport;
// mother widget that contains everything
SAssignNew(YagHUDWidget, SYagHUDWidget)
.YagHUD(TWeakObjectPtr<AYagHUD>(this));
// add the mother widget
// WHEN COMMENTING THIS LINE, THE HOVERING WORKS FINE
//Viewport->AddViewportWidgetContent(SNew(SWeakWidget).PossiblyNullContent(YagHUDWidget.ToSharedRef()));
}
}
So That’s definitely a problem of interaction with the UI that appeared with 4.9 migration (thanks DerChris for pointing me to the UI).
It sounds like it is a problem with the cursor colliding with the widget, not the OnBeginCursorOver event per se. I would suggest using the ‘Widget Reflector’ to determine which widget is being hit, and disabling hit testing with it.
This is assuming that your main widget is just the default canvas panel with the other UI widgets as a part of it. You can select the Canvas Panel of the main widget and in the details panel set the Visibility drop down to Self Hit Test Invisible. This should cause only the main widget to ignore hit tests but not affect any of its children so you can still use the other UI elements.
This solved it for me also.
I previously tried to set only the canvases of the menus to EVisibility::SelfHitTestInvisible, but that didn’t do it. Setting the whole menu worked like a charm. Interestingly it’s buttons still work if menu is set to EVisibility::SelfHitTestInvisible.