Where is KeyEvent function called on?

Discussions about Coding and Scripting
User avatar
PrinceOfFunky
Godlike
Posts: 1204
Joined: Mon Aug 31, 2015 10:31 pm

Where is KeyEvent function called on?

Post by PrinceOfFunky »

I know the classes WindowConsole and Console have this event:

Code: Select all

event bool KeyEvent( EInputKey Key, EInputAction Action, FLOAT Delta )
Is that event called only on specific instances or it can be called on multiple instances?
User avatar
Barbie
Godlike
Posts: 2955
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Where is KeyEvent function called on?

Post by Barbie »

I'm a bit confused by your question :omfg: Do you want to simulate input events?
I think it works the other way - see comment in Console.uc:
// Called by the engine when a key, mouse, or joystick button is pressed
// or released, or any analog axis movement is processed.
That function is called by the engine in case of an input event so that UScript programmers can react on what the player is doing. If there is more than one instance of the class Console, the function should be called at those instances, too.
"If Origin not in center it be not in center." --Buggie
User avatar
PrinceOfFunky
Godlike
Posts: 1204
Joined: Mon Aug 31, 2015 10:31 pm

Re: Where is KeyEvent function called on?

Post by PrinceOfFunky »

Barbie wrote:If there is more than one instance of the class Console, the function should be called at those instances, too.
That's what I want, but it doesn't get called.
These are the two classes I'm using:

Code: Select all

class InputCapture extends Mutator;

event PostBeginPlay() {
	local TestWindow testWindow;
	local UWindowRootWindow root;
	
	testWindow = new class'TestWindow';
	root = new class'UWindowRootWindow';
	
	root.Console = testWindow;
	testWindow.root = root;	
}

Code: Select all

class TestWindow extends WindowConsole;

event bool KeyEvent( EInputKey Key, EInputAction Action, FLOAT Delta ) {
	Log(Key@Action);
	
	return true;
}

state UWindow {}