mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
ui/app: (iOS) check for first responder status before changing focus
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+20
-6
@@ -167,19 +167,33 @@ NSArray<UIKeyCommand *> *_keyCommands;
|
|||||||
|
|
||||||
- (void)willMoveToWindow:(UIWindow *)newWindow {
|
- (void)willMoveToWindow:(UIWindow *)newWindow {
|
||||||
if (self.window != nil) {
|
if (self.window != nil) {
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIWindowDidBecomeKeyNotification object:self.window];
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIWindowDidResignKeyNotification object:self.window];
|
name:UIWindowDidBecomeKeyNotification
|
||||||
|
object:self.window];
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
|
name:UIWindowDidResignKeyNotification
|
||||||
|
object:self.window];
|
||||||
}
|
}
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onWindowDidBecomeKey:) name:UIWindowDidBecomeKeyNotification object:newWindow];
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onWindowDidResignKey:) name:UIWindowDidResignKeyNotification object:newWindow];
|
selector:@selector(onWindowDidBecomeKey:)
|
||||||
|
name:UIWindowDidBecomeKeyNotification
|
||||||
|
object:newWindow];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(onWindowDidResignKey:)
|
||||||
|
name:UIWindowDidResignKeyNotification
|
||||||
|
object:newWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onWindowDidBecomeKey:(NSNotification *)note {
|
- (void)onWindowDidBecomeKey:(NSNotification *)note {
|
||||||
onFocus((__bridge CFTypeRef)self, YES);
|
if (self.isFirstResponder) {
|
||||||
|
onFocus((__bridge CFTypeRef)self, YES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onWindowDidResignKey:(NSNotification *)note {
|
- (void)onWindowDidResignKey:(NSNotification *)note {
|
||||||
onFocus((__bridge CFTypeRef)self, NO);
|
if (self.isFirstResponder) {
|
||||||
|
onFocus((__bridge CFTypeRef)self, NO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
|
|||||||
Reference in New Issue
Block a user