When there are multiple Windows, drag and drop no longer works.
jcampbell05 opened this issue · 5 comments
jcampbell05 commented
When there are multiple windows, CoreDragon does try to loop though them but upon not finding a source on the first window it will return nil, the fix is as simple as making sure to only return a source when looping through the windows if there actually is one, otherwise carry on looping:
- (SPDragSource*)sourceUnderLocation:(CGPoint)locationInWindow
{
for(UIWindow *window in [UIApplication sharedApplication].windows) {
UIView *view = [window hitTest:locationInWindow withEvent:nil];
SPDragSource *source = nil;
do {
source = objc_getAssociatedObject(view, kDragSourceKey);
if (source)
break;
view = [view superview];
} while(view);
// FIX STARTS HERE
if (source)
return source;
}
return nil;
}
jcampbell05 commented
There appears to be the same thing with drop target as well.
nevyn commented
@jcampbell05 Thank you!! Would you mind providing this fix as a pull request?
nevyn commented
Nm fixed it myself, thanks :)
jcampbell05 commented
@nevyn haha, sorry about this. works great going to ship in an app !
nevyn commented
@jcampbell05 yay!! did you ship? which app?