iOS: Be more thorough when looking for current first responder
The technique of sending an action does not always end up at the actual first responder, but it will end up in a responder in the responder chain of the first responder, so we continue searching the subviews recursively until we find the real first-responder. Change-Id: I6abc9bc18eb127fa4b317cd308783c0ecfcd670a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
parent
d563f6142b
commit
c432960718
@ -152,6 +152,22 @@ int infoPlistValue(NSString* key, int defaultValue)
|
||||
@implementation QtFirstResponderEvent
|
||||
@end
|
||||
|
||||
|
||||
@implementation UIView (QtFirstResponder)
|
||||
- (UIView*)qt_findFirstResponder
|
||||
{
|
||||
if ([self isFirstResponder])
|
||||
return self;
|
||||
|
||||
for (UIView *subview in self.subviews) {
|
||||
if (UIView *firstResponder = [subview qt_findFirstResponder])
|
||||
return firstResponder;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation UIResponder (QtFirstResponder)
|
||||
|
||||
+(id)currentFirstResponder
|
||||
@ -164,7 +180,11 @@ int infoPlistValue(NSString* key, int defaultValue)
|
||||
- (void)qt_findFirstResponder:(id)sender event:(QtFirstResponderEvent *)event
|
||||
{
|
||||
Q_UNUSED(sender);
|
||||
event.firstResponder = self;
|
||||
|
||||
if ([self isKindOfClass:[UIView class]])
|
||||
event.firstResponder = [static_cast<UIView *>(self) qt_findFirstResponder];
|
||||
else
|
||||
event.firstResponder = [self isFirstResponder] ? self : nil;
|
||||
}
|
||||
@end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user