bug(mac): IMKStateSetting protocol: '- (NSDictionary *)modes:(id)sender' method doesn't work
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
Originally reported to Apple with radar 22655952. Now tracking at [FB6007877](https://feedbackassistant.apple.com/feedback/6007877).
According to the IMKStateSetting Protocol reference; by calling the `- (NSDictionary *)modes:(id)sender` method, the input method can dynamically modify the modes supported, instead of reading the modes from the Info.plist file. However, when we return a dictionary similar to the one in Info.plist file, it is ignored and modes don't appear in the input sources.
Steps to Reproduce:
Following method is provided in an IMKInputController subclass, it gets called but doesn't seem to work.
```objc
- (NSDictionary *)modes:(id)sender {
NSLog(@"*** modes ***");
if (_kmModes == nil) {
NSDictionary *amhMode = [[NSDictionary alloc] initWithObjectsAndKeys:
@"keyman.png",
kTSInputModeAlternateMenuIconFileKey,
[NSNumber numberWithBool:YES],
kTSInputModeDefaultStateKey,
[NSNumber numberWithBool:YES],
kTSInputModeIsVisibleKey,
@"A",
kTSInputModeKeyEquivalentKey,
[NSNumber numberWithInteger:4608],
kTSInputModeKeyEquivalentModifiersKey,
[NSNumber numberWithBool:YES],
kTSInputModeDefaultStateKey,
@"keyman.png",
kTSInputModeMenuIconFileKey,
@"keyman.png",
kTSInputModePaletteIconFileKey,
[NSNumber numberWithBool:YES],
kTSInputModePrimaryInScriptKey,
@"smUnicodeScript",
kTSInputModeScriptKey,
@"amh",
@"TISIntendedLanguage",
nil
];
NSDictionary *hinMode = [[NSDictionary alloc] initWithObjectsAndKeys:
@"keyman.png",
kTSInputModeAlternateMenuIconFileKey,
[NSNumber numberWithBool:YES],
kTSInputModeDefaultStateKey,
[NSNumber numberWithBool:YES],
kTSInputModeIsVisibleKey,
@"H",
kTSInputModeKeyEquivalentKey,
[NSNumber numberWithInteger:4608],
kTSInputModeKeyEquivalentModifiersKey,
[NSNumber numberWithBool:YES],
kTSInputModeDefaultStateKey,
@"keyman.png",
kTSInputModeMenuIconFileKey,
@"keyman.png",
kTSInputModePaletteIconFileKey,
[NSNumber numberWithBool:YES],
kTSInputModePrimaryInScriptKey,
@"smUnicodeScript",
kTSInputModeScriptKey,
@"hin",
@"TISIntendedLanguage",
nil
];
NSDictionary *modeList = [[NSDictionary alloc] initWithObjectsAndKeys:
amhMode,
@"com.apple.inputmethod.amh",
hinMode,
@"com.apple.inputmethod.hin",
nil];
NSArray *modeOrder = [[NSArray alloc] initWithObjects:
@"com.apple.inputmethod.amh",
@"com.apple.inputmethod.hin",
nil
];
_kmModes = [[NSDictionary alloc] initWithObjectsAndKeys:
modeList,
kTSInputModeListKey,
modeOrder,
kTSVisibleInputModeOrderedArrayKey,
nil
];
}
return _kmModes;
}
```
Expected Results: It is expected that the provided modes would appear in the input sources menu to add, as it would appear when the modes dictionary is provided in the Info.plist file. Actual Results: Modes dictionary is ignored and only 1 input source is created. Version: Xcode 6.4 (6E35b) Mac OS X version 10.10.5 (14F27)
Notes: This issue was reported to Apple Technical Support before and IMKit engineers have reviewed and determined that this would be best handled as a bug report.
Contributor guide
Assessment
This issue has not been assessed yet.