InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

Propagate navigation events up in hierarchy in InputSystemUIInputModule

Open f1yingbanana opened this issue 3 years ago • 2 comments

Description

Imagine a panel containing a single selected button, where pressing the escape key should dismiss the panel. The most intuitive way to implement this is to wire up the escape key with a cancel event in the EventSystem. Button, which is the currently selected object, doesn't implement ICancelHandler, so naturally it should let another UI element higher up in the hierarchy, a script attached to the panel, do the work.

This currently doesn't happen, as the event is not propagated up the hierarchy. This PR adds an option (default false for compatibility) to surface IMoveHandler, ISubmitHandler and ICancelHandler up the hierarchy for a custom UI element to handle them.

Changes made

Added a new flag propagateNavigationEvents to InputSystemUIInputModule, so that when the flag is true, IMoveHandler, ISubmitHandler and ICancelHandler are invoked with ExecuteHierarchy instead of a simple Execute.

f1yingbanana avatar Jul 18 '21 05:07 f1yingbanana

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: f1yingbanana
:x: Jiacong Xu


Jiacong Xu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

unity-cla-assistant avatar Jul 18 '21 05:07 unity-cla-assistant

Thanks for the contribution. Looks like a good change to me. Raised it internally in team.

Rene-Damm avatar Aug 13 '21 11:08 Rene-Damm