How to have a right click event on a HUD button?

Hey all working on some inventory stuff and I want the player to be able to right click on items in the inventory to see options of what they can do with it.

I can do it fine with left click but I want left click to be the control for a different function, however it doesn’t seem like it’s possible to do a on right click event for buttons, I can do a Is mouse button down with a true/false but since it’s not a pointer event I can’t plug an input into it.

So how do you do a right click event for HUD buttons?

Any help appreciated thanks

How would this work if the button is part of a larger hud though,? How would calling on mouse button down work for multiple inventory buttons?

Well the player can only add a finite amount of items to inventory so they are just set to hidden and then when an item is added to the inventory the first one is unhidden, then the next etc, etc…

Just the defaults though I can try making a custom button hud tonight after work, no idea how tog o about that but I’m sure it’s not that hard and there’s probably plenty of tuts anyways, so good start tbh, thanks

You need to create your custom button widget (if you haven’t already). There you override OnMouseButtonDownFunction like so:

But if you just want to display info you can do it with OnHovered

3 Likes

It would work the same way as OnClicked, OnPressed etc. It’s up to you to update the “options” text whenever the button is clicked. But as I said you need to create your custom button widget. The call Right Click is and event dispatcher that you can bind and assign to.

More info is needed about your buttons. I assume they are dynamically created and added to your HUD, right?

1 Like

You just create a new widget BP and in there place a button and override OnMouseButtonDown like in the picture (style it however you want). Then in your main widget use that button instead of the default button.

1 Like

I know this is old but I finally got to this I ended up working on other misc. projects lmao. And I got it setup correctly but it seems I can’t actually edit how the button looks or it’s functions?

That is only if it’s part of a larger hud. If I just go into the custom widget bp I can edit it however I like but that means I’d have to create a new right click button widget for every single button in my project.

I have a advanced inventory system i am building and my left and right clicks do two different codes so it can be done would just need to know more about what you wanna do you can always make the each mouse button right click different depending on the button your in anyone needing help can email me at imstilldabs@gmail.com for a faster reply.or more in-depth help.

You can expose what ever you want to be modified, for example, the color. Inside your button widget create a color variable and make it Public. Then on Event Pre-construct set the color of the button to use the color from the variable. Then in your HUD widget you can modify the color of the button. In the image I’ve attached it’s the same button but with different colors, text and behavior.

305292-buttons.png

1 Like