microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Long press for Presablebuttons #10285

Closed FlorianJa closed 9 months ago

FlorianJa commented 2 years ago

I would like to create similar button functionality as from the OS buttons in the start menu to open something like a context menu when a user pushes a button for a longer time (1 or 2 seconds).

The Interactable script provides the OnHoldReceiver with the functionlity I am looking for. However, this does only work properly when using the Far interaction. "Physically" pushing the button also triggers the OnHold event but also the OnClick Event. I would like to suppress the OnClick Event (from the PressableButton -> PhysicalPressEventRouter -> Interactable) when the button is pressed physically similar to the way it is done for the far interaction.

To reproduce

Steps to reproduce the behavior:

  1. open the HandInteractionExamples scene.
  2. create a short script to show the events in the console, something like this:
    
    public void OnClick()
    {
    Debug.Log("OnClick");
    }

public void OnHold() { Debug.Log("OnHold"); }


4. select a pressable button and wire up the event (from the reveiver region)
3. check the console output for far and near interaction.
4. You will see, that the OnClick AND the OnHold event will be triggered if you push the button (but not if you do it with the far interaction)

## Expected behavior

When the button is pushed for a longer time AND a OnHold event listener is defined, the OnClick event should suppressed.

## Your setup (please complete the following information)

- Unity Version 2020.03.20
- MRTK Version 2.7 (latest main commit)

## Target platform (please complete the following information)

- HoloLens 2
- 
## Additional context
I labeled this with "Bug" even if it is more like a feature request because the behaviour for far and near interaction is different.
I already created a "fix" for this and I will create a pull request.
stale[bot] commented 2 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

IssueSyncBot commented 9 months ago

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!