From 173d56a67a600ec89568789f86f450e8f1f442b8 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 20 Jun 2019 19:05:06 +0200 Subject: [PATCH] ui/app: (ios) relay system focus events Signed-off-by: Elias Naur --- ui/app/os_ios.go | 6 ++++++ ui/app/os_ios.m | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/ui/app/os_ios.go b/ui/app/os_ios.go index 2d5f2401..fabc7911 100644 --- a/ui/app/os_ios.go +++ b/ui/app/os_ios.go @@ -110,6 +110,12 @@ func onDestroy(view C.CFTypeRef) { w.view = 0 } +//export onFocus +func onFocus(view C.CFTypeRef, focus int) { + w := views[view] + w.w.event(key.Focus{Focus: focus != 0}) +} + //export onLowMemory func onLowMemory() { runtime.GC() diff --git a/ui/app/os_ios.m b/ui/app/os_ios.m index 6eda6364..db2605a3 100644 --- a/ui/app/os_ios.m +++ b/ui/app/os_ios.m @@ -36,6 +36,16 @@ static void redraw(CFTypeRef viewRef, BOOL sync) { GioViewController *controller = [[GioViewController alloc] initWithNibName:nil bundle:nil]; controller.screen = self.window.screen; self.window.rootViewController = controller; + [[NSNotificationCenter defaultCenter] addObserverForName:UIWindowDidBecomeKeyNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + UIView *view = self.window.rootViewController.view; + if (view != nil) + onFocus((__bridge CFTypeRef)view, YES); + }]; + [[NSNotificationCenter defaultCenter] addObserverForName:UIWindowDidResignKeyNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + UIView *view = self.window.rootViewController.view; + if (view != nil) + onFocus((__bridge CFTypeRef)view, NO); + }]; [self.window makeKeyAndVisible]; return YES; } -- 2.34.2