Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

hide show menu, prevent input trigger by PC?

I'm using this to try hide/show my menu. But it seems the PC is triggering input after the UI did (they both look for the same key) making the menu show up again... If I change the UI key it will work fine, I can also hack it kindof by holding down the key for a bit.

This is the code I'm using atm, can someone tell me what I am doing wrong? Thanks!

 // IN UI
 FReply UPlayerMenu::NativeOnKeyDown(const FGeometry & InGeometry, const FKeyEvent & InKeyEvent)
     if (InKeyEvent.GetCharacter() == 'I')
         printc("Close Menu", Blue);
         ALPlayerController* PC = (ALPlayerController*)GetWorld()->GetFirstPlayerController();
         return FReply::Handled();
     return FReply::Unhandled();
 // IN PC
 void ALPlayerController::TogglePlayerMenu()
     APlayerHUD* PlayerHUD = (APlayerHUD*)GetHUD();
     if (PlayerHUD->ActiveMenu == EActiveMenu::AE_None)
         printc("Show menu", Cyan);
         printc("Hide menu", Cyan);
 // IN PlayerHUD
 void APlayerHUD::ShowInventory()
     printc("Drawing PlayerUI", Green);
     if (InventoryMenuClass)
         printc("Show menu", Green);
         ActiveMenu = EActiveMenu::AE_Inventory;
         FInputModeUIOnly Mode;
         GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true;
 void APlayerHUD::HideInventory()
     if (InventoryMenuClass)
         ActiveMenu = EActiveMenu::AE_None;
         FInputModeGameOnly GameMode;
         GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false;
Product Version: UE 4.8
more ▼

asked Aug 10 '15 at 10:46 AM in C++ Programming

avatar image

71 8 8 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey Unhek-

Rather than check input in the UI it would be better practice to do this in the player controller. You can setup the action mapping in the project settings with the name of the action and the related key. Then in the Character class you can assign which function to call when the action is taken. The Third Person code template has a good example of this in how the Jump function is setup in the character class.


Doug Wilson

more ▼

answered Aug 10 '15 at 08:24 PM

avatar image Unhek Aug 11 '15 at 05:52 PM

Thanks, I will look into this, I did however fix this problem simply by updating to 4.9. I read somewhere here (forgot where) that there was something strange in the FReply event handling in 4.8, making handled events act like unhandled event sometimes, not clear on how or what. Tough the update without changing any code did fix the issue for me. Thanks for the help, this does indeed feel like a more logical approach

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question