UDN
Search public documentation:

GFxKeyFilters
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > User Interfaces & HUDs > Scaleform GFx > bCaptureInput, AddCaptureKey and AddFocusIgnoreKey Guide

bCaptureInput, AddCaptureKey and AddFocusIgnoreKey Guide


Overview


Input needs to be filtered so that when the player does press a button or move an analogue stick the correct response is given. This improves the usability of the user interface dramatically.

bCaptureInput


Setting this to true in the default properties of your class will send all input (mouse, keyboard, and game controller) to the Flash class/SWF, instead of the game. Setting it to false allows all input to go to the game instead.

Unrealscript
defaultproperties
{
  bCaptureInput=true or false
}

AddFocusIgnoreKey


If you set bCaptureInput to true, you can exclude individual keys from being capture by the SWF file and instead allow them to pass through to the game using AddFocusIgnoreKey.

Unrealscript
AddFocusIgnoreKey('W');

AddCaptureKey


If you set bCaptureInput to false, you can include individual keys to be captured by the SWF file, instead of allowing them to pass through to the game.

Unrealscript
AddCaptureKey('W');

Example List of Capturable Keys


The following list should be used when capturing or ignoring keys:

  • 1 - 0, A - Z, F1 - F12
  • Up, Down, Left, Right
  • Spacebar, Enter, Escape
  • BackSpace, LeftControl, RightControl
  • LeftShift, RightShift, PageUp
  • PageDown, Home, Insert
  • Equals, Minus, Tab
  • LeftAlt, RightAlt

In Kismet, however, when using the Set GFx Captured Keys node, you may need to use the spelled out names of numbers, instead of the digits:

  • one, two, three, ...

Intercepting Input in ActionScript


Once you are capturing a key(s) via UnrealScript or Kismet, you can listen for those keys in ActionScript with the following code:

ActionScript
import flash.external.ExternalInterface;

var keyboardInput:Object = new Object(); // creates a new object to hold keyboard input.
Key.addListener(keyboardInput); // uses the object to listen for keyboard input.

/* when a key is pressed, execute this function. */
keyboardInput.onKeyDown = function()
{
    /* store the keyboard input ASCII code inside 'keyPressed'. */
    var keyPressed:Number = Key.getCode();
    trace("Key Pressed" + keyPressed);

    /* Call the UnrealScript function 'KeyPressed' and send it the 'keyPressed' value. */
    ExternalInterface.call("KeyPressed", keyPressed);
}

The code stored in keyPressed is an ASCII value.

ALERT! Note: The preferred path for keyboard input is usually going to be binding keys to functions defined in the DefaultInput.ini file. Then these UnrealScript functions can tell Flash movie clips what to do. There are, however, some situations where you'll want specific keys at specific times to go to the Flash file instead.