Where is KeyEvent function called on?

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

Where is KeyEvent function called on?

Post by PrinceOfFunky » Tue Dec 12, 2017 6:24 am

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?
"Your stuff is known to be buggy and unfinished/not properly tested"

User avatar
Barbie
Godlike
Posts: 2107
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Where is KeyEvent function called on?

Post by Barbie » Tue Dec 12, 2017 8:09 am

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.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
PrinceOfFunky
Godlike
Posts: 1160
Joined: Mon Aug 31, 2015 10:31 pm

Re: Where is KeyEvent function called on?

Post by PrinceOfFunky » Tue Dec 12, 2017 8:13 am

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 {}
"Your stuff is known to be buggy and unfinished/not properly tested"