~eliasnaur/gio

173d56a67a600ec89568789f86f450e8f1f442b8 — Elias Naur 2 years ago b9205d9
ui/app: (ios) relay system focus events

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2 files changed, 16 insertions(+), 0 deletions(-)

M ui/app/os_ios.go
M ui/app/os_ios.m
M ui/app/os_ios.go => ui/app/os_ios.go +6 -0
@@ 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()

M ui/app/os_ios.m => ui/app/os_ios.m +10 -0
@@ 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;
}