@@ -914,11 +914,15 @@ internal void ProcessNavigation(ref NavigationModel navigationState)
914914
915915 data . device = m_SubmitCancelState . device ;
916916
917- if ( cancelAction != null && cancelAction . WasPerformedThisDynamicUpdate ( ) )
917+ if ( cancelAction != null && m_NavigationState . wasCancelButtonReleased )
918918 ExecuteEvents . Execute ( eventSystem . currentSelectedGameObject , data , ExecuteEvents . cancelHandler ) ;
919- if ( ! data . used && submitAction != null && submitAction . WasPerformedThisDynamicUpdate ( ) )
919+ if ( ! data . used && submitAction != null && m_NavigationState . wasSubmitButtonReleased )
920920 ExecuteEvents . Execute ( eventSystem . currentSelectedGameObject , data , ExecuteEvents . submitHandler ) ;
921921 }
922+
923+ // We clear the following flags here to mark that we've processed them already
924+ m_NavigationState . wasSubmitButtonReleased = false ;
925+ m_NavigationState . wasCancelButtonReleased = false ;
922926 }
923927
924928 private bool IsMoveAllowed ( AxisEventData eventData )
@@ -1403,7 +1407,7 @@ public InputActionReference move
14031407 public InputActionReference submit
14041408 {
14051409 get => m_SubmitAction ;
1406- set => SwapAction ( ref m_SubmitAction , value , m_ActionsHooked , m_OnSubmitCancelDelegate ) ;
1410+ set => SwapAction ( ref m_SubmitAction , value , m_ActionsHooked , m_OnSubmitDelegate ) ;
14071411 }
14081412
14091413 /// <summary>
@@ -1443,7 +1447,7 @@ public InputActionReference submit
14431447 public InputActionReference cancel
14441448 {
14451449 get => m_CancelAction ;
1446- set => SwapAction ( ref m_CancelAction , value , m_ActionsHooked , m_OnSubmitCancelDelegate ) ;
1450+ set => SwapAction ( ref m_CancelAction , value , m_ActionsHooked , m_OnCancelDelegate ) ;
14471451 }
14481452
14491453 /// <summary>
@@ -2287,11 +2291,6 @@ private void OnMoveCallback(InputAction.CallbackContext context)
22872291 m_NavigationState . device = context . control . device ;
22882292 }
22892293
2290- private void OnSubmitCancelCallback ( InputAction . CallbackContext context )
2291- {
2292- m_SubmitCancelState . device = context . control . device ;
2293- }
2294-
22952294 private void OnTrackedDeviceOrientationCallback ( InputAction . CallbackContext context )
22962295 {
22972296 var index = GetPointerStateIndexFor ( ref context ) ;
@@ -2318,6 +2317,26 @@ private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context
23182317#endif
23192318 }
23202319
2320+ private void OnSubmit ( InputAction . CallbackContext context )
2321+ {
2322+ m_SubmitCancelState . device = context . control . device ;
2323+
2324+ if ( ! context . ReadValueAsButton ( ) )
2325+ {
2326+ m_NavigationState . wasSubmitButtonReleased = true ;
2327+ }
2328+ }
2329+
2330+ private void OnCancel ( InputAction . CallbackContext context )
2331+ {
2332+ m_SubmitCancelState . device = context . control . device ;
2333+
2334+ if ( ! context . ReadValueAsButton ( ) )
2335+ {
2336+ m_NavigationState . wasCancelButtonReleased = true ;
2337+ }
2338+ }
2339+
23212340 private void OnControlsChanged ( object obj )
23222341 {
23232342 m_NeedToPurgeStalePointers = true ;
@@ -2509,12 +2528,14 @@ private void HookActions()
25092528 m_OnScrollWheelDelegate = OnScrollCallback ;
25102529 if ( m_OnMoveDelegate == null )
25112530 m_OnMoveDelegate = OnMoveCallback ;
2512- if ( m_OnSubmitCancelDelegate == null )
2513- m_OnSubmitCancelDelegate = OnSubmitCancelCallback ;
25142531 if ( m_OnTrackedDeviceOrientationDelegate == null )
25152532 m_OnTrackedDeviceOrientationDelegate = OnTrackedDeviceOrientationCallback ;
25162533 if ( m_OnTrackedDevicePositionDelegate == null )
25172534 m_OnTrackedDevicePositionDelegate = OnTrackedDevicePositionCallback ;
2535+ if ( m_OnSubmitDelegate == null )
2536+ m_OnSubmitDelegate = OnSubmit ;
2537+ if ( m_OnCancelDelegate == null )
2538+ m_OnCancelDelegate = OnCancel ;
25182539
25192540 SetActionCallbacks ( true ) ;
25202541 }
@@ -2532,14 +2553,14 @@ private void SetActionCallbacks(bool install)
25322553 m_ActionsHooked = install ;
25332554 SetActionCallback ( m_PointAction , m_OnPointDelegate , install ) ;
25342555 SetActionCallback ( m_MoveAction , m_OnMoveDelegate , install ) ;
2535- SetActionCallback ( m_SubmitAction , m_OnSubmitCancelDelegate , install ) ;
2536- SetActionCallback ( m_CancelAction , m_OnSubmitCancelDelegate , install ) ;
25372556 SetActionCallback ( m_LeftClickAction , m_OnLeftClickDelegate , install ) ;
25382557 SetActionCallback ( m_RightClickAction , m_OnRightClickDelegate , install ) ;
25392558 SetActionCallback ( m_MiddleClickAction , m_OnMiddleClickDelegate , install ) ;
25402559 SetActionCallback ( m_ScrollWheelAction , m_OnScrollWheelDelegate , install ) ;
25412560 SetActionCallback ( m_TrackedDeviceOrientationAction , m_OnTrackedDeviceOrientationDelegate , install ) ;
25422561 SetActionCallback ( m_TrackedDevicePositionAction , m_OnTrackedDevicePositionDelegate , install ) ;
2562+ SetActionCallback ( m_SubmitAction , m_OnSubmitDelegate , install ) ;
2563+ SetActionCallback ( m_CancelAction , m_OnCancelDelegate , install ) ;
25432564 }
25442565
25452566 private static void SetActionCallback ( InputActionReference actionReference , Action < InputAction . CallbackContext > callback , bool install )
@@ -2649,13 +2670,14 @@ private struct InputActionReferenceState
26492670
26502671 private Action < InputAction . CallbackContext > m_OnPointDelegate ;
26512672 private Action < InputAction . CallbackContext > m_OnMoveDelegate ;
2652- private Action < InputAction . CallbackContext > m_OnSubmitCancelDelegate ;
26532673 private Action < InputAction . CallbackContext > m_OnLeftClickDelegate ;
26542674 private Action < InputAction . CallbackContext > m_OnRightClickDelegate ;
26552675 private Action < InputAction . CallbackContext > m_OnMiddleClickDelegate ;
26562676 private Action < InputAction . CallbackContext > m_OnScrollWheelDelegate ;
26572677 private Action < InputAction . CallbackContext > m_OnTrackedDevicePositionDelegate ;
26582678 private Action < InputAction . CallbackContext > m_OnTrackedDeviceOrientationDelegate ;
2679+ private Action < InputAction . CallbackContext > m_OnSubmitDelegate ;
2680+ private Action < InputAction . CallbackContext > m_OnCancelDelegate ;
26592681 private Action < object > m_OnControlsChangedDelegate ;
26602682
26612683 // Pointer-type input (also tracking-type).
0 commit comments