# How do you receive input in AHUD \[C++\]

**URL:** <https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 4, 2014, 1:00pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618 "2014-04-04T13:00:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [April 4, 2014, 1:00pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/1 "2014-04-04T13:00:29Z")

</div>

Hi!

How should you setup your player controller class and a custom HUD class in order to being able to receive mouse inputs?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [April 4, 2014, 1:23pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/2 "2014-04-04T13:23:02Z")

</div>

You can use FViewport and FViewportClient to recive mouse input on game screen

> **[FViewport](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/FViewport/)**
>
> Encapsulates the I/O of a viewport.

You can grab viewport object of your viewport from GEngine-\> GameViewport

You could also try to use Slate for gui (if you want to make more RTSish HUD) it should have ready click events, but currently Slate is not very well documented.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [April 5, 2014, 1:04pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/3 "2014-04-05T13:04:35Z")

</div>

Is there a way to get the events in AHUD to trigger like e.g. ReceiveHitBoxClick or are you supposed to trigger those yourself?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [April 5, 2014, 1:47pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/4 "2014-04-05T13:47:44Z")

</div>

Oh i didnt know about those 🙂 Look on source code you just need tocCreate hitbox with AddHitBox:

AddHitBox(Position, Size, Name, bConsumesInput, Priority = 0)

And then override ReceiveHitBoxClick(FName Name) in your HUD class which will be called when hitbox is clicked and it will give name of clicked hitbox in Name.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [April 5, 2014, 3:23pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/5 "2014-04-05T15:23:44Z")

</div>

I though so too but it doesn’t work for me, hmm… Anyway if I don’t find a solution soon I will stick to your first answer and implement a similar “GUI hitbox” system myself. I’m probably missing some flag or similar during initiation of my objects.

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [April 7, 2014, 2:19pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/6 "2014-04-07T14:19:39Z")

</div>

#800+ Lines of Code, Sample HUD Class Writing to Canvas

I have posted an 800+ line complete sample class, and a VIDEO demoing it here:

[800+ Line Sample HUD Class](https://wiki.unrealengine.com/HUD,_Canvas,_Entire_Class_Sample,_Create_Buttons_%26_Draw_Materials)

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [April 8, 2014, 10:32am UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/7 "2014-04-08T10:32:32Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![GregBlast](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GregBlast](https://forums.unrealengine.com/u/GregBlast)\
**Post date:** [April 19, 2014, 2:00pm UTC](https://forums.unrealengine.com/t/how-do-you-receive-input-in-ahud-c/279618/8 "2014-04-19T14:00:59Z")

</div>

I was wondering the exact same thing. After watching a video demoing how to use hit box in a HUD from a blueprint I tried doing it in C++ with no luck. Could anyone point us to what we are missing ?
