From 6fc70bef99b90e1917d0f0e130e2cd00d808826f Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Fri, 11 Mar 2016 16:14:16 +0100 Subject: [PATCH] Enable hiding OSK on OS X --- src/frameworks/UBPlatformUtils_mac.mm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/frameworks/UBPlatformUtils_mac.mm b/src/frameworks/UBPlatformUtils_mac.mm index 1bbb6a22..8f8c667d 100644 --- a/src/frameworks/UBPlatformUtils_mac.mm +++ b/src/frameworks/UBPlatformUtils_mac.mm @@ -601,17 +601,21 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget) void UBPlatformUtils::showOSK(bool show) { - // TODO: enable hiding OSK - - if (show) { - [[NSAutoreleasePool alloc] init]; + @autoreleasepool { + CFDictionaryRef properties = (CFDictionaryRef)[NSDictionary + dictionaryWithObject: @"com.apple.KeyboardViewer" + forKey: (NSString *)kTISPropertyInputSourceID]; - CFDictionaryRef properties = - (CFDictionaryRef)[NSDictionary - dictionaryWithObject: @"com.apple.KeyboardViewer" - forKey: (NSString *)kTISPropertyInputSourceID]; NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, false); - TISSelectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]); + if ([sources count] > 0) { + if (show) + TISSelectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]); + else + TISDeselectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]); + } + + else + qWarning() << "System OSK not found"; } }