OSX: allow OSK to be shown even if user didn't first enable it in system prefs

also added error handling and displaying to the user.
preferencesAboutTextFull
Craig Watson 8 years ago
parent 7f3b790328
commit f70ff4acf9
  1. 26
      src/frameworks/UBPlatformUtils_mac.mm

@ -605,16 +605,30 @@ void UBPlatformUtils::showOSK(bool show)
dictionaryWithObject: @"com.apple.KeyboardViewer"
forKey: (NSString *)kTISPropertyInputSourceID];
NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, false);
NSArray *sources = (NSArray *)TISCreateInputSourceList(properties, true);
if ([sources count] > 0) {
if (show)
TISSelectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]);
else
TISDeselectInputSource((TISInputSourceRef)[sources objectAtIndex: 0]);
TISInputSourceRef osk = (TISInputSourceRef)[sources objectAtIndex: 0];
OSStatus result;
if (show) {
TISEnableInputSource(osk);
result = TISSelectInputSource(osk);
}
else {
TISDisableInputSource(osk);
result = TISDeselectInputSource(osk);
}
if (result == paramErr) {
qWarning() << "Unable to select input source";
UBApplication::showMessage(tr("Unable to activate system on-screen keyboard"));
}
}
else
else {
qWarning() << "System OSK not found";
UBApplication::showMessage(tr("System on-screen keyboard not found"));
}
}
}

Loading…
Cancel
Save