Fix triggerchanged event not firing from touch v3#5149
Merged
dmarcos merged 2 commits intoaframevr:masterfrom Nov 16, 2022
Merged
Fix triggerchanged event not firing from touch v3#5149dmarcos merged 2 commits intoaframevr:masterfrom
dmarcos merged 2 commits intoaframevr:masterfrom
Conversation
- button would be undefined if the onButtonChangedV3 function was ran
dmarcos
reviewed
Nov 9, 2022
| // move the button meshes | ||
| if (this.isOculusTouchV3) { | ||
| this.onButtonChangedV3(evt); | ||
| this.onButtonChangedV3(button, evt); |
Member
There was a problem hiding this comment.
can we define a variable button inside onButtonChangedV3 to decouple branches?
this.onButtonChangedV3(evt);
and
var button = this.mapping[this.data.hand].buttons[evt.detail.id]; inside
dmarcos
reviewed
Nov 10, 2022
|
|
||
| onButtonChanged: function (evt) { | ||
| var button = this.mapping[this.data.hand].buttons[evt.detail.id]; | ||
| if (!button) { return; } |
Member
There was a problem hiding this comment.
Not sure I fully understand the bug now. Since we were already checking the button existence in onButtonChangedV3 and early returing. this and old code should be equivalent
Contributor
Author
There was a problem hiding this comment.
This jsfiddle is the simplest demonstration of what I mean https://jsfiddle.net/1xgnzv58/3/
That is what the current code does. If I have a touch v3 controller, it won't fire the triggerchanged event.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
I found that the
triggerchangedevent was not firing with the current A-Frame master build, asbuttonwas undefined inonButtonChangedif the V3 code path was taken.Changes proposed:
buttonis identical in both functions, it can be moved out and passed along to the V3 function when necessary. This puts it back in scope to be referenced for the event emit.