Input stack order

If I understand the documentation regarding the Input stack and consuming input correctly, the on_input functions in scripts will be called in the reversed order the “acquire input”-calls was made. That should mean that if I create a collection from a collection proxy all game objects within that collection acquiring input in their init-function should have precedence over any script loaded before the proxy was loaded.

However, I have a general script that handles most in-game input. There are two different gui-screens loaded through two different collection proxies that can be shown as modal overlays during game play. These should consume input and stop the in-game script from receiving input. Both gui-scenes therefore returns true in the on_input-function.
The strange thing though is that only one of these actually ends up before the in-game script in the input-stack. The other one will be called after and so any input is consumed by the in-game script first.

Have I missunderstood something?

This is a bit tricky. There is an input stack for each loaded collection, but input is fed to the loaded collection stack through the main collection stack and the position of the collection proxy component in that stack dictates when that happen.

Do you have specific reasons why you load the GUI screens by proxy? If you could add the GUI screen collections as sub-collections in each level instead of loading them, then all input listeners in the collection would be part of the main input stack.

Is this correct? I’m trying to figure out how to define the input stack order in my game.

Edit: I suppose so?

Input stack

The list of input listeners with the first acquirer of focus at the bottom of the stack and the last acquirer at the top.

Correct, the name stack refers to how the data is organized. Imagine a stack of hey, the most recent hay is at the top, and to get to the older hay, you’d have to dig deeper.

2 Likes