macOS Catalina - экранная (виртуальная) клавиатура не работает - PullRequest
1 голос
/ 21 октября 2019

Я использовал приведенный ниже код, чтобы показать виртуальную экранную клавиатуру, и до сих пор работал хорошо до 10.14, но он больше не работает на Catalina (10.15). На Catalina он больше не может создавать источники ввода, и он всегда пуст -

+ (void) showHideVirtualKeyboard:(BOOL) shouldShow {


    NSDictionary *property = [NSDictionary dictionaryWithObject:(NSString*)kTISTypeKeyboardViewer
                                                         forKey:(NSString*)kTISPropertyInputSourceType];
    NSLog(@"showHideVirtualKeyboard my dictionary is - %@",property);
    NSArray *sources = (__bridge NSArray*)TISCreateInputSourceList((__bridge CFDictionaryRef)property, false);
    if([sources count] == 0) {
        DBLogError(@"ToggleKeyboard: no input keyboard source type found...");
        DBLogError(@"ToggleKeyboard: Trying to create keyboard soruce type");
        sources = (__bridge NSArray*)TISCreateInputSourceList((__bridge CFDictionaryRef)property, true);
        if ([sources count]==0) {
            DBLogError(@"ToggleKeyboard: Still can't find any input sources so nothing to...");
            if(sources)
                CFRelease((CFTypeRef)sources);
            return;
        }
    }

    TISInputSourceRef keyboardViewer = (__bridge TISInputSourceRef)[sources objectAtIndex:0];
    //DBLogInfo(@"********** received sources are %@",keyboardViewer);
    int osStatus;
    //let's show hide keyboard
    if (shouldShow == YES){
        CFBooleanRef enabled = TISGetInputSourceProperty(keyboardViewer, kTISPropertyInputSourceIsEnabled);
        if (enabled == kCFBooleanFalse)
            TISEnableInputSource(keyboardViewer);
        // DBLogInfo(@"kTISPropertyInputSourceIsEnabled = %@",(enabled == kCFBooleanFalse)?@"false":@"true");
        osStatus = TISSelectInputSource(keyboardViewer);
    }
    else
        osStatus = TISDeselectInputSource(keyboardViewer);

    if(osStatus !=noErr)
        DBLogInfo(@"ToggleKeyboard: Received errored OSStatus and it is (%d) ",osStatus);
    if(sources)
        CFRelease((CFTypeRef)sources);
}

Пожалуйста, сообщите, если кто-нибудь сталкивался с подобной проблемой, и любое решение / обходной путь доступен.

Спасибо.

...