Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Adding the ability to subclass UIGestureRecognizer#1002

Closed
pittmab wants to merge 1 commit into
microsoft:developfrom
autodesk-forks:Subclass-UIGestureRecognizer
Closed

Adding the ability to subclass UIGestureRecognizer#1002
pittmab wants to merge 1 commit into
microsoft:developfrom
autodesk-forks:Subclass-UIGestureRecognizer

Conversation

@pittmab

@pittmab pittmab commented Sep 13, 2016

Copy link
Copy Markdown
Contributor
  • removing the hard coded preference of gestures
  • now enumerating the list of gestures in the order in which they are added
  • supporting some of the callbacks for UIGestureRecognizerDelegate
  • Adding a callback to check if the first active gesture can prevent other potential gestures in the gesture recognizer list.

Fix: 489
Fix: 475


This change is Reviewable

@msftclas

Copy link
Copy Markdown

Hi @pittmab, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

Comment thread Frameworks/UIKit/UIView.mm Outdated
UIGestureRecognizer* activeGesture = nil;

int count = [g_currentlyTrackingGesturesList count];
for (int i = count - 1; i >= 0; i--) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be converted into a for in loop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aballway I am guessing that you would prefer that we use a reverseObjectEnumerator to traverse in reverse order. I have noticed that the code in this file uses a mixture of old for counting loops and for in loops. Should all new code be for in when it can? I initially used the style I found in the existing code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better style to use for in loops unless the index is needed or the entire file is in counting style. Given this file is mixed either one would work, but I believe using for/in is clearer.


In reply to: 78584341 [](ancestors = 78584341)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aballway I agree that for in is quicker to read so I will make the changes. Just curious as to what your team prefers given the mix in this file. I will make the changes.

@jaredhms

Copy link
Copy Markdown
Contributor

@davelamb, please take a look.

Comment thread Frameworks/UIKit/UIView.mm Outdated
}
}

if ( activeGesture ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activeGesture [](start = 8, length = 15)

super-nit: several spots with inconsistent spacing; it may be beneficial to run pre_commit(.ps1) or pre_push(.ps1) which would run clang-format over your changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaredhms I just ran it and it doesn't indicate that any changes are necessary. Is there something that I am missing? Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have this file staged with changes?


In reply to: 78603657 [](ancestors = 78603657)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited the file and ran the pre-commit check. The output was Performing pre-commit validation... Commit approved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange; it should have modified the file in place to remove the spacing inconsistencies. it might be worth trying .\tools\scripts\clang-format.ps1 -File to see if you get different results?


In reply to: 78604452 [](ancestors = 78604452)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I have to run clang-format. Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - that's a bit unfortunate. Might be worth trying pre_push next time (after you commit, before you push)...


In reply to: 78605310 [](ancestors = 78605310)

@pittmab pittmab force-pushed the Subclass-UIGestureRecognizer branch from 08aa54c to 7269fc0 Compare September 13, 2016 17:05
Comment thread Frameworks/UIKit/UIView.mm Outdated
// remove those gesturee
for ( UIGestureRecognizer* curGesture in gesturesToRemove ) {
[curGesture reset];
TraceVerbose(TAG, L"Removing gesture %hs %x state=%d", object_getClassName(curGesture), curGesture );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TraceVerbose(TAG, L"Removing gesture %hs %x state=%d", object_getClassName(curGesture), curGesture ); [](start = 9, length = 104)

can you please wrap this in an 'if (DEBUG_GESTURES) {}' ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaredhms Added and other changes have been made. Please take a look.

@pittmab pittmab force-pushed the Subclass-UIGestureRecognizer branch from 7269fc0 to dc5fe0e Compare September 13, 2016 17:37
Comment thread Frameworks/UIKit/UIView.mm Outdated
for (UIGestureRecognizer* curGesture in [g_currentlyTrackingGesturesList reverseObjectEnumerator]) {
id curgestureClass = [curGesture class];
if ([curgestureClass _fireGestures:@[ curGesture ]]) {
handled = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be 'true', shouldn't it?

Also can we please add the old tracing back?

        if (handled && DEBUG_GESTURES) {
            TraceVerbose(TAG, L"Gesture (%hs) handled.", object_getClassName(curgestureClass));
        }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaredhms Fixed and the original debugging code put back. Thanks

- removing the hard coded preference of gestures
- now enumerating the list of gestures in the order in which they are added
- supporting some of the callbacks for UIGestureRecognizerDelegate
- Adding a callback to check if the first active gesture can prevent other potential gestures in the gesture recognizer list.

Fix: 489
Fix: 475
@pittmab pittmab force-pushed the Subclass-UIGestureRecognizer branch from dc5fe0e to 1c72432 Compare September 14, 2016 15:31
@jaredhms

Copy link
Copy Markdown
Contributor

:shipit:

@bbowman

bbowman commented Sep 23, 2016

Copy link
Copy Markdown
Member

Seems like this would merit some sort of UT to validate. I know @davelamb mentioned not having UI automation yet but I don't think the test needs to be that extreme to prove out that the subclassing works and that the code you changed is operating correctly / not regressing things etc.

@bbowman

bbowman commented Sep 23, 2016

Copy link
Copy Markdown
Member

🕐

@yiyang-msft

Copy link
Copy Markdown
Contributor

Hi, @pittmab,

I merge your code into a new pull request #1909, would you mind taking a look? The gesture code has gone through significant changes since this request. It would be a loteasier for me to pull your code into latest code and working on top of it.

Thanks
Yi

@tadam-msft

Copy link
Copy Markdown
Member

As seen in the thread the pull request was incorporated into another pull request and checked in. This pull request is no longer needed.

@tadam-msft tadam-msft closed this Apr 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants