x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

OnBeginCursorOver and OnEndCursorOver Only fired when mouse is clicked over static mesh.

Hello, the topic says the main problem. These events get fired only when I have my mouse over my static mesh and when these functions are implemented the OnClicked function doesn't get fired anymore... I have tried to do this with both c++ and blueprint. I can get the OnClicked event working correctly. I have set the bEnableMouseOverEvents to true in my controller and it is the right controller.

Here is my .h code:

 UFUNCTION(Category = Default)
 void Numpad1OnClick(UPrimitiveComponent* pComponent, FKey inKey);
 
 UFUNCTION(Category = Default)
 void Numpad1OnHover(class UPrimitiveComponent * pComponent);
 
 UFUNCTION(Category = Default)
 void Numpad1OnLeave(class UPrimitiveComponent* pComponent);

And here is necessary parts in the cpp

Getting the controller and doing the settings:

 APlayerController* controller = UGameplayStatics::GetPlayerController(this->GetWorld(), 0);
 controller->bShowMouseCursor = true;
 controller->bEnableClickEvents = true;
 controller->bEnableMouseOverEvents = true;

Binding functions to events:

 numpadKey1->OnClicked.AddDynamic(this, &AAccessPanel::Numpad1OnClick);
 numpadKey1->OnBeginCursorOver.AddDynamic(this, &AAccessPanel::Numpad1OnHover);
 numpadKey1->OnEndCursorOver.AddDynamic(this, &AAccessPanel::Numpad1OnLeave);

And the functions themselves:

 void AAccessPanel::Numpad1OnClick(UPrimitiveComponent * pComponent, FKey inKey)
 {
     UE_LOG(LogTemp, Warning, TEXT("Number 1 CLICKed!"));
 }
 
 void AAccessPanel::Numpad1OnHover(class UPrimitiveComponent * pComponent)
 {
     UE_LOG(LogTemp, Warning, TEXT("Number 1 mouse OVER!"));
 }
 
 void AAccessPanel::Numpad1OnLeave(class UPrimitiveComponent * pComponent)
 {
     UE_LOG(LogTemp, Warning, TEXT("Number 1 mouse LEFT!"));
 }

I have tried changing the collision types of my static mesh but it doesn't solve this and I think that CursorOver and EndCursorOver should work if OnClicked works? Anything more I can try or is this a bug?

Product Version: UE 4.12
Tags:
more ▼

asked Aug 11 '16 at 05:46 PM in C++ Programming

avatar image

Piilorasva
18 2 11 9

avatar image Piilorasva Aug 11 '16 at 05:58 PM

And a little update. I made UBoxComponent and tried to get this working with that but the same problem remains.

avatar image Piilorasva Aug 11 '16 at 06:25 PM

And even more info and it gets more weird. If I have bEnableMouseOverEvents enabled but don't have these events set to be handled my mesh won't recognice the OnClicked even't anymore. So only way to recognize OnClicked is to let bEnableMouseOverEvents to be false. Why is this?

avatar image room101 Aug 15 '16 at 08:46 PM

perhaps this may help?

avatar image Piilorasva Aug 22 '16 at 05:38 AM

I tried setting all the other meshes to ignore all trace and physic channels but the problem remains.

avatar image room101 Aug 22 '16 at 06:24 PM

I'm sorry to hear that. This is the code that worked for me immediately without any other change in the actual meshes components, I added it in BeginPlay:

GetCapsuleComponent()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);

//add over events

GetCapsuleComponent()->OnClicked.AddDynamic(this, &ADA2UE4Creature::OnClick);

GetCapsuleComponent()->OnBeginCursorOver.AddDynamic(this, &ADA2UE4Creature::BeginCursorOver);

GetCapsuleComponent()->OnEndCursorOver.AddDynamic(this, &ADA2UE4Creature::EndCursorOver);

and in your header file make sure that your functions are marked as UFUNCTION(), but I think you already did that

Thanks!

avatar image Piilorasva Aug 27 '16 at 11:59 AM

Finally tested this a bit further. I made a new blank 3rd person project and I got the click, over and end events working as intended in that in both blueprint and c++. I doublechecked my previous project for a chance that there is some collision in front of my event handling collision but there is nothing, not in the world or in my player block the visibility channel before the collision I want to handle the events. I even made a new blank blueprint object with nothing but a single box and event for that and the result was same as before = the mouse over and end events are only handled when mouse is clicked. One notice that I did is that when input mode is set to UiOnly even the clicking doesn't help, the mode must be set to GameAndUi to even get the events working when clicked. Any ideas?

avatar image Piilorasva Aug 29 '16 at 01:31 PM

And more updates. Seems like my code should be fine indeed. Today I noticed that in this project I cannot get the 3d widget ui working like it should and again I got it working in a blank project by following the same steps. So seems like something is messing with the ui interaction in my main project. Any ideas for things i could check? It seems like something in the FInputMode is not working.

avatar image room101 Aug 29 '16 at 03:28 PM

I'm sorry, no other ideas :(

avatar image Piilorasva Aug 29 '16 at 03:47 PM

Just got it working :) I will write about it as an answer.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Finally found the solution. I had to set the visibility of my custom WIDGET to ESlateVisibility::HitTestInvisible. I already had all my texts, buttons etc. set to this inside my widget, but I didn't know that I had to do it for the widget itself.

more ▼

answered Aug 29 '16 at 03:48 PM

avatar image

Piilorasva
18 2 11 9

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question