RustyE
April 29, 2021, 3:26pm
1
I have successfully implemented Marc’s script to add keyboards to Keyman with Java script, now I need to be able to select/change/show a keyboard.
When I select the keyboard from the Keyman OSK selector, I’m able to grab the ISOcode, but I can’t seem to be able to tell Keyman to display the new keyboard (language).
i.e.
const tags = [‘en’,‘fr’,‘ta’];
kmw.addKeyboards(…tags.map(tag => ‘@’+tag));
I’d like to be able to programmatically change the keyboard display to (for example) French.
Thanks in advance,
Rusty
Marc
April 30, 2021, 8:23pm
2
You can switch keyboards with setActiveKeyboard
or for control-by-control presets, you can use setKeyboardForControl
.
@RustyE Does the solution Marc provided works for you?
RustyE
May 19, 2021, 11:22am
4
No, I can’t get them to work in the MVC environment.
I’ve tried this:
/script>
var kmw = keyman;
(function (kmw) {
kmw.init({ attachType: 'auto' });
var tags = @Html.Raw(Json.Encode(Model.PreferredKeyboards));
kmw.addKeyboards(...tags.map(tag => '@@' + tag))
var alert = confirm("KMW reloading")
kmw.setDefaultKeyboardForControl('#CKSource', 'en', 'Eng');
kmw.setDefaultKeyboardForControl('#CKTarget', 'hi', 'hin');
})(keyman);
/script>
(the /script has had the < removed to pass injection/errors in this blog)
Let me know if you can get this to work.
Marc
May 20, 2021, 10:34pm
5
See conversation continuing in Asp.net Keyman web with ckEditor - #8 by RustyE
I’ll mark this thread as resolved