Download

Mouse Clicking on Inventory Menu

Hey guys,

I’ve set up an inventory HUD system using the simple canvas interface (Draw HUD). I’ve got the HUD displaying properly and I’ve enabled mouse events, click events and mouse over events.

My question is that I’m trying to change the appearance of a single HUD item (in this case I’m just using Draw Rect for simplicity) when the mouse hovers over it.

I see the Event Actor Begin Cursor Over node, but that’s assuming my actor is the entire HUD blueprint and I’m just trying to grab a single rectangle that’s drawn to the screen.

I’m checking the Blueprint Mouse Interaction demo for mouse info, and it works great for assets that have their own blueprints but doesn’t (to my knowledge) mention anything about HUD elements.

Anyone know how to determine if the mouse is overlapping a HUD element that’s being drawn?

Thanks!

Hello Zooch,
That is pretty easy to do, just like a Draw Rect node there is an Add Hit Box node for you to use!
it works just like a Draw Rect node, but do keep in mind that the “Name” variable for “Add Hit Box” must be unique for each hitbox you create!

To receive events for those new HUD hitboxes, all you need is the node named “Event receive hit box click” or the equivalent “mouse over” event nodes.
The events will output the unique names you’ve given your hitboxes, making life a whole lot easier.

Let me know how it goes, if you find yourself stuck I’ll send you my example of an inventory system.

Cheers!

Worked like a charm! Thanks so much!

Got a quick follow-up question for you (I should probably just go to bed and think about it on my own tomorrow).

It was simple to get one hitbox name from the ‘Event Receive Hit Box Begin Cursor Over’ event node, but my logic is flawed for multiple hitboxes. For the sake of simplicity, let’s say I have two rectangles, named Rect1 and Rect2.

I’ve properly named them in the hitbox, but the event node I’m using can only be used once, and it has an output for the Name. I can set that name to Rect1 or Rect2, then toggle a ‘Hovering’ boolean to enact my state logic (if hover, change color of the box to green; if not hover, change it to red).

I can’t simply hook the event node up to Rect1 and Rect2, else the logic will fire for both (mouse over Rect1 and both boxes turn green). How are you keeping the logic independent when you’re only using one event node for begin/end hover over?

I use a Switch on Name node and put in the names of each of my hitboxes. That way it only fires for the one that’s being hit.

I actually (unfortunately) dreamed about this exact solution last night while sleeping. That means it must be brilliant, right?

Right!?

Thanks Tom!