Download

Strange Mouse Click Behaviour on an Array: Only works correctly for last element...

What I’m trying to do is click on some icons to select them, then when the mouse has been clicked away from all of the icons, detect that the mouse has been clicked and then deselect the currently selected icon.

I have my icon actors in an array, and my problem is that when I use an Action Mapping set in the Input settings to detect left click combined with a mouseOver boolean that I set to true with BeginCursorOver and false with EndCursorOver(because there doesn’t seem to be any built in event that would work for clicking away from an Actor), the behaviour only seems to work correctly for the last element of the array.

The mouseOver boolean is definitely being set correctly, the problem is that when I click it always reads the correct value for the last element of the array and not the one the mouse is hovering over. i.e. It’s always False unless I’m over the icon of the last element of the array. It’s almost as though mouseOver is acting like a static variable but I know those don’t exist in Blueprints.

Only thing I can think of: Is that just how input mappings work? That they’re inappropriate for iterating through an array and setting a local variable because they fire in some strange way? How do they work exactly compared to normal events? I’m guessing it’s being fired for every event (which makes sense now I think about it, but I still don’t know what else to do) but even still I find it strange that only one Print String function is output when I click…

Either way that leaves the ultimate question of: How can I detect when an object is being clicked away from? OnClicked is fine for clicking on something… but input mappings are all I could see for detecting if the mouse has been clicked when AWAY from an object.