Skip to content

How to access Events "OnToggled" and "OnUntoggled" of a PressableButton? #11813

Answered by AMollis
ArDevKarl asked this question in Q&A
Discussion options

You must be logged in to vote

Use the StatefulInteractable.IsToggled TimedFlag object. Types of TimedFlag have an OnEntered and OnExited event you can register to.

https://learn.microsoft.com/en-us/dotnet/api/mixedreality.toolkit.statefulinteractable.istoggled?view=mrtkcore-3.0&viewFallbackFrom=mrtkuxcore-3.0#mixedreality-toolkit-statefulinteractable-istoggled

https://learn.microsoft.com/en-us/dotnet/api/mixedreality.toolkit.timedflag?view=mrtkcore-3.0

private void AddEventHandlers(PressableButton button)
{
    button.IsToggled.OnEntered.AddListener(OnButtonToggledEntered);
    button.IsToggled.OnExited.AddListener(OnButtonToggledExited);
}

private void RemoveEventHandlers(PressableButton button)
{
    button.IsToggled.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ArDevKarl
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #11812 on February 13, 2024 17:34.