From 6f044afc49e324d30d84163eafe125f79bb07db8 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 12 Jan 2016 17:37:00 +0100 Subject: [PATCH] Added support for OSX on-screen keyboard --- src/board/UBBoardController.cpp | 9 +++++++++ src/frameworks/UBPlatformUtils.h | 1 + src/frameworks/UBPlatformUtils_mac.mm | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 99af72b7..b11114cf 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -94,6 +94,10 @@ bool onboardIsAlreadyRunning = true; #endif +#ifdef Q_OS_OSX +#include +#endif + UBBoardController::UBBoardController(UBMainWindow* mainWindow) : UBDocumentContainer(mainWindow->centralWidget()) , mMainWindow(mainWindow) @@ -853,6 +857,11 @@ void UBBoardController::showKeyboard(bool show) } else mPaletteManager->showVirtualKeyboard(show); + +#elif defined(Q_OS_OSX) + if(UBSettings::settings()->useSystemOnScreenKeybard->get().toBool()) + UBPlatformUtils::showOSK(); + #else mPaletteManager->showVirtualKeyboard(show); #endif diff --git a/src/frameworks/UBPlatformUtils.h b/src/frameworks/UBPlatformUtils.h index 0b28c7dd..368ae84a 100644 --- a/src/frameworks/UBPlatformUtils.h +++ b/src/frameworks/UBPlatformUtils.h @@ -208,6 +208,7 @@ public: #ifdef Q_OS_OSX static void SetMacLocaleByIdentifier(const QString& id); + static void showOSK(); #endif }; diff --git a/src/frameworks/UBPlatformUtils_mac.mm b/src/frameworks/UBPlatformUtils_mac.mm index 1ec487aa..a9bbbe57 100644 --- a/src/frameworks/UBPlatformUtils_mac.mm +++ b/src/frameworks/UBPlatformUtils_mac.mm @@ -609,3 +609,16 @@ void UBPlatformUtils::showFullScreen(QWidget *pWidget) } + +void UBPlatformUtils::showOSK() +{ + [[NSAutoreleasePool alloc] init]; + + CFDictionaryRef properties = + (CFDictionaryRef)[NSDictionary + dictionaryWithObject: @"com.apple.KeyboardViewer" + forKey: (NSString *)kTISPropertyInputSourceID]; + NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, false); + + TISSelectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]); +}