Announcement

Collapse
No announcement yet.

binding umg buttons to input keys

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    binding umg buttons to input keys

    This is probably a dumb question but how do you go about binding a umg button to lets say the 1 key? been trying to figure this out for a few hours not and cant seem to figure it out. MY buttons are set up for a hotbar (or action bar which ever you prefer) the button it self gets called from another widget but i have all the hot bars assigned to a specific slot so that the slot number can get called from any blueprint if needed. but i cant seem to get it to acknowledge that the button was pressed.

    #2
    Set Inputmode to the widget wich should grab the key add key event to to widgets graph and well do as you would normaly do
    Free Inventory System (BP AND C++ Version): Clicky Clicky
    Player Structure System (Houses!) (BP): Pew Pew Marketplace Version: Yoink!
    Howto: Create Dragable UMG Windows: Zoom Zoom

    Comment


      #3
      im not understanding the key event any chance you can elaborate a bit. cause the way im working it is that that from the spell blueprint it will find which slot number its in on the hot bar and as long as that icon is in the slot thats pressed it will cast its spell but i cant seem to set up the number inputs from the keyboard . and i cant find anything that will key bind a button. so if you could elaborate that would be great.


      thanks

      Comment


        #4
        I asked a similar question : https://answers.unrealengine.com/que...shortcuts.html

        It seems there isn't a "native" way to do it yet, umg with keyboard and pad isn't as good as it is with the mouse yet.

        Comment


          #5
          ill try those out thanks wish they just had it setup to enable keybinding

          Comment


            #6
            We're still working on controller input and general input improvements to UMG. You always have the ability to override the incoming keys from slate via the overridable functions on the widget. But those require that focus is on your widget. That is to say, your hot bar would require that it or a child widget has focus. That's the way real UI systems work for better or worse. While it may sound like a hassle for a small simple UI, it's incredibly important if you're building a very complicated UI system.

            So - what do you do?

            The answer is to not have input bound to UI. Instead the input binding should be performed by the standard input binding system, the same way you would bind jump or move forward. You don't bind 1 to the button you bind it to PerformSlot1Action. The underlying game code then maps that binding to some UObject's function/event in a blueprint of the pawn/character...etc and executes the right action. The UI similarly would ask the pawn/character to perform whatever the action is for the ActionSlot it's mapped to when clicked. Think of Buttons and other UI elements as just another game pad that can send commands.

            Comment


              #7
              I asked the same question and after several days I came to a conclusion that it's not possible, in how you wanted it anyway. Actually, I think this is a very major problem because I wanted a button control for my flight mobile game but I couldn't do it. With virtual joystick awful gameplay, I changed the whole project as a PC/Console project and targeted to Steam Greenlight now. But I really, really...."really" wanted to make a mobile game with the great control manouverability of the PC controls. I wish UMG gets the data directly from input -which gets it's data from whatever blueprint it represents.

              So my hope in near future (I hope anyway, not too far ) UMG will support direct On-Bind events from input buttons.
              voidrunnerthegame.com

              facebook.com/voidrunnergame

              Comment


                #8
                well after doing everything i can think of i found out that i can change the number of the slot no problem but only viewed as a print string. which means there is no communication at all to the child widgets. which in turn means we cant set them at all unless nick has an example to show us . i spent the past few hours just trying to change the value of the number i have set up thats connected to my slot widget . but that number wont change no matter what i do. so now im at a loss. nick if you got an example for this it would be really appreciated cause i cant figure it out.

                thanks

                Comment


                  #9
                  Originally posted by Wanderer_eternal View Post
                  So my hope in near future (I hope anyway, not too far ) UMG will support direct On-Bind events from input buttons.
                  i second this. being able to pull the input event from the character is a must for UMG.

                  Comment


                    #10
                    Originally posted by invayne View Post
                    i second this. being able to pull the input event from the character is a must for UMG.
                    I third this.
                    @thereisnoscotty
                    Grand Marshal of the Parade of Madfellows

                    Comment


                      #11
                      ive been faking it by changing the opacity of the images depending on character ability cooldowns. then i can just bind keyboard events to the same custom event s that are fired by the buttons. https://www.dropbox.com/s/hwxjbk5hbl...02-26.flv?dl=0

                      Comment


                        #12
                        I remember in UE4.6 I felt screwed and just plain gave up and went mouse only. Attempting to have the normal input system communicate with the widget was crashing the engine so badly I couldn't even open my project without deleting the widget first. I haven't tried it in UE4.7 yet. It sounds like it might work without crashing this time, but You really need a native input system for UMG. Doesn't even seem like it would be that hard.
                        Strife - 1996 - Remake

                        Comment


                          #13
                          Hello invayne,

                          I believe I have a answer that may be viable to the original question of how to setup OnKeyDown/OnkeyUp events inside of widgets. I hope this helps.

                          You will need to use the OnKeyDown/OnkeyUp override function that can be found in the MyBlueprint panel.

                          Click image for larger version

Name:	KeyboardInputHelp3.png
Views:	1
Size:	44.3 KB
ID:	1071104

                          Here is an example of an OnKeyDown function. This function checks to see if the key pressed is the '1' key. If it is it will print out a line saying something to the effect of "That is the 1 key alright!" and if not it will say "That's the wrong key". Please not that you may want to include a not equal to node that will return the keyboard focus to normal. I have done this with the escape key in this example.

                          Click image for larger version

Name:	KeyboardInputHelp1.png
Views:	1
Size:	208.4 KB
ID:	1071105

                          The keyboard focus needs to be set for the widget you would like to use the keyboard inputs for, otherwise it will not be looking for them. NOTE: as long as the keyboard focus in on the widget it will consume all keyboard inputs. This is why you would need some way to "UNset" the focus. In the case of these examples you will see that I set the input mode to game and UI in the above picture.

                          Click image for larger version

Name:	KeyboardInputHelp2.png
Views:	1
Size:	68.5 KB
ID:	1071106

                          Make it a great day

                          Comment


                            #14
                            Looks like a pretty good solution, especially paired with Rama's rebindable key functions. Thanks, Rudy!
                            @thereisnoscotty
                            Grand Marshal of the Parade of Madfellows

                            Comment


                              #15
                              It doesn't look pretty, but it works! I'm so glad because this has been bugging me for a while. I used a macro because it was originally going to branch, but then I decided to have it not only test the key, but take action as well. Thank God my menu will never have more than 6 options! It would get even uglier.
                              Click image for larger version

Name:	menu1.png
Views:	1
Size:	357.9 KB
ID:	1071229Click image for larger version

Name:	menu2.png
Views:	1
Size:	291.4 KB
ID:	1071230
                              Strife - 1996 - Remake

                              Comment

                              Working...
                              X