I am making an keybinding menu and in ActionScript3 when click a button (GFxClikWidget, not kb or mouse button) I am calling an UnrealScript function GetKeyPress which returns GFxObject containing a String(AS_String). The GetKeyPress function should wait for a button press (kb/mouse btn), capture it and then return the name of the button that is pressed. (I’ve set bCaptureInput to false so I could capture key press in my PlayerInput class)
The thing I don’t know how to do is how to wait for a button to be pressed before returning the GFxObject containing a String with it’s name back to AS3?
In my PlayerImput class i can add to DefaultProperties “OnReceivedNativeInputKey=KeyInput” which executes KeyInput everytime a key is pressed, Then in KeyInput function I can set some variable with the name of the pressed button. Then i can access that variable in GetKeyPress function and return it to AS3. But how to wait in GetKeyPress function for the button press?
PS. I want to capture the pressed button with UnrealScript and then return it’s name to AS3 because if I capture the button press with AS3 it will be ASCII code which then I have to convert somehow to UDK button name.
OK I figured out how to do the binding menu. It’s not how I wanted it originaly but it works.
Intead of making variable retVal in AS and expecting US to return pressed key to that variable i just set the button label to “Press any key” and sent void function call to US. Then in US function i set a bool property (class variable) named bPressed to true (by default it’s false). Then in another function named “bool FilterButtonInput” with which you can capture every keypress i check if the bPressed is set to true and if it is I set the button’s label to the button name that is pressed (this func captures the button name too). Then i set the bPressed to false again. Here is the code (I simplified (and changed) it a bit because actually I don’t have a button in AS3 but a list with custom renderer with button inside, so I replaced the stuff I do with setting a button’s label) :
var btnLabel = button.label;
button.label = "Press any key";
But the way the code works now it returns MouseLeftClick to AS3 because that was the key I used to click the GFxClik button. But what I need is to click the GFxClik button, the function GetKeyPress to wait for another key press and then send that key name back to AS3 (like in all games key binding menus, you click button then it says press key and waits for keypress and when you press some key the button label changes with that key name). So before
I need to wait and for another keypress and return that to AS3 because if I don’t wait it returns MouseLeftClick which is what I used to click the GfxClik button itself.
I know that if you use the GFxUDKFrontEnd system you will push a dialog that works as a hook and this dialog waits for keypress and when it recieves keypress it the dialog pops out and sends the pressed key somewhere but I don’t use the GFxUDKFrontEnd system and i don’t have push/pop dialog functionality.