Stop mouse/key event propagation

Ability to stop key or mouse press/release event propagation after it was handled, e.g. trigger once and stop propagation

When using multiple layers or scenes that are reacting to same key or mouse press there is no simple way to ignore previous input (trigger once works only on that particular event)

Supporting evidence
Use cases are better described by other frameworks having this like Web APIs (event.stopPropagation()), Godot (handled=true) and QML (event.accepted=true).

There is quite some examples across the forum of the same question and solutions of using visibility checks, extra variables and/or timers (e.g. here) but that is definitely cumbersome.

Simple example to reproduce it with keys:

In Base scene

In Pause scene

As both scenes react to key this will show “Pause” scene and then quickly hide it.

I made a quick workaround to simulate stop propagation

This is obviously a hack and ideally there would be an accepted or handled property for a key or mouse event which could be set when wanted and checked later when needed.

Let me know your opinions and if I’m missing something,

Best regards

I don’t think there’s anything wrong with the concept behind this request, but just for context I think your example solution goes a bit heavier than needed.

For my use case, I just use a global boolean variable. I require it to be false as a condition on my events that need a stop option, and set it true as the last action of those events. Then I have a single event that sets it back to false when the button/key is not pressed (NOT the released conditions. The “pressed” or mouse button down conditions, inverted)

Your method should work fine, but a js event might be heavier/more complex than needed when it can be accomplished with a global variable.

(To be clear, I agree it would be nice to have an option natively in events. )