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

**URL:** <https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360>\
**Category:** UI\
**Tags:** hud, click-event, unreal-engine, mouse-click, question, Blueprint\
**Created:** [January 9, 2020, 3:43pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360 "2020-01-09T15:43:02Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [January 9, 2020, 3:43pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/1 "2020-01-09T15:43:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [January 9, 2020, 3:56pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/2 "2020-01-09T15:56:23Z")

</div>

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

 ![295045-rc.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/1/4/014ca367ef680c56bfda7d198391677c1e97f256.png)

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

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [January 9, 2020, 4:13pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/3 "2020-01-09T16:13:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [January 9, 2020, 4:23pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/4 "2020-01-09T16:23:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [January 9, 2020, 5:28pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/5 "2020-01-09T17:28:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [January 9, 2020, 6:44pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/6 "2020-01-09T18:44:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PerCat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/percat/32/479573_2.png) [@PerCat](https://forums.unrealengine.com/u/PerCat)\
**Post date:** [March 16, 2020, 3:00pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/7 "2020-03-16T15:00:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DonleyStudiosInc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DonleyStudiosInc](https://forums.unrealengine.com/u/DonleyStudiosInc)\
**Post date:** [March 16, 2020, 5:36pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/8 "2020-03-16T17:36:31Z")

</div>

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](mailto:imstilldabs@gmail.com) for a faster reply.or more in-depth help.

---

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [June 24, 2020, 1:33pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/9 "2020-06-24T13:33:58Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/9/0a90b941138bb317d54b05f661db5f1e35d4deed.png)

---

<div class="post-metadata">

**Author:** ![Felnion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Felnion](https://forums.unrealengine.com/u/Felnion)\
**Post date:** [June 26, 2024, 2:11pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/10 "2024-06-26T14:11:26Z")

</div>

I’m attempting to have a button on screen to select an object with left click and bring up a new border if the selected object is right clicked… So far everything is set up and working except for the right click. I don’t fully understand how to call on this event dispatcher after I put my custom button into my GamePlay UMG. How do I use this new custom button in a different UMG and have the ability to either right click or left click it to call two different events or functions? I’m not too familiar with event dispatchers yet so I’m sorry if this seems like a dumb question.

Edit: Never mind… It appears that as soon as I place the custom button into my widget and make it a variable) I get the option to use “Call Right Click” 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 26, 2024, 2:25pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/11 "2024-06-26T14:25:17Z")

</div>

Let’s say this is the _button_, here it’s made out of a simple border, overriding `onButtonDown`:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/6/136c935c7f98d603422c1e612149bb4d44ffc056.png)

We click the border, figure out whether it was the left button and call the dispatcher.

> [@Felnion](#):
>
> How do I use this new custom button in a different UMG

That’d depend on what / where that different UMG is. However, if you simply add this custom button to a widget, you can flag it as a variable and the dispatcher’s delegate will be available immediately:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/7/e576255ba6412cf1d04dee2e6ce4350020c3c957.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/f/0ffe9ce44fc345480727c5cae9ed01f674169a99.png)

* * *

If the listening widget is unrelated to the one with the button that broadcasts the click, you’ll need to bind the event dynamically. If you need a more concrete example, you’d need to explain the dependency between the widgets that need to communicate.

---

<div class="post-metadata">

**Author:** ![Felnion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Felnion](https://forums.unrealengine.com/u/Felnion)\
**Post date:** [June 26, 2024, 2:31pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/12 "2024-06-26T14:31:43Z")

</div>

Thank you for the quick response! I was confusing myself by looking at the button events in the custom button’s button (Wow that was a mouth full). After adding the new custom button to my main UMG (and ticking the “is variable”) the event appears and is hopefully usable the way that I intend it to be. You are awesome and I appreciate you! 🙂

---

<div class="post-metadata">

**Author:** ![Felnion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Felnion](https://forums.unrealengine.com/u/Felnion)\
**Post date:** [June 26, 2024, 6:43pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/13 "2024-06-26T18:43:29Z")

</div>

One more quick question… How would I go about adding a shift click option? I’ve tried a few ways to no avail…

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 26, 2024, 7:53pm UTC](https://forums.unrealengine.com/t/how-to-have-a-right-click-event-on-a-hud-button/460360/14 "2024-06-26T19:53:13Z")

</div>

• ensure the widget is keyboard focusable and give it keyboard focus so it can detect keys going down  
• override `onKeyDown` =\> check which key =\> set a new ShiftIsDown bool `true` (or `false` if key is undesired)  
• when RMB goes down, query the abovementioned flag
