Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard does not appear after adding a new keyboard #6

Closed
jmdurdin opened this issue Dec 17, 2014 · 1 comment
Closed

Keyboard does not appear after adding a new keyboard #6

jmdurdin opened this issue Dec 17, 2014 · 1 comment
Milestone

Comments

@jmdurdin
Copy link

Using Keymanweb 2.0 build 396.

Can dynamically add a keyboard from a html select list on a form, but cannot display the keyboard to the form. The user must manually mouse click on the keyboard from the keyboard menu to display the keyboard.

Here is the code:

(function(kmw) { 
    kmw.init();   
    if ($("#id_language_code").val() == 'ar' ) {
        kmw.addKeyboards('arabic_101'); // this will add the keyboard.
        kmw.setActiveKeyboard('Keyboard_arabic_101','arb'); // this should display the vkb .
    } else if ($("#id_language_code").val() == 'ru' ) {
        kmw.addKeyboards('russian'); // this will add the keyboard
        kmw.setActiveKeyboard('Keyboard_russian','rus'); // this should display the vkb 
    }       
}...

The code appears to be correct, but the API does not work as documented.

@jmdurdin
Copy link
Author

The main issue is that a delay is needed between installing and activating the keyboard.

The steps needed are:

  1. add the keyboard (using addKeyboards).
  2. wait until it has been added and is available to be selected
  3. select that keyboard, specifying both the (internal) keyboard name and language code
  4. set the focus to any editable element (otherwise the OSK will not appear)
  5. tell KeymanWeb to display the OSK

Here is one way to do that. Include the following function:

  function useKeyboard(kbdName,elId)
  {
    var kmw=tavultesoft.keymanweb,kbd=kmw.getKeyboard('Keyboard_'+kbdName); 
    if(kbd == null)
    {
       var tWait=(arguments.length > 2 ? arguments[2] : 10000);
       if (tWait > 0) window.setTimeout(function () { useKeyboard(kbdName, elId, tWait - 50); }, 50);
    }
    else
    {
          kmw.setActiveKeyboard(kbd.InternalName, kbd.LanguageCode);
          document.getElementById(elId).focus();
          kmw.osk.show(1);     
    }
  }

then call it with the keyboard name and an element id after your call to addKeyboards(), for example:

var kmw=window.tavultesoft.keymanweb;
kmw.addKeyboards('arabic_101');
useKeyboard('arabic_101','ta1');

@mcdurdin mcdurdin added this to the Support milestone Aug 18, 2023
SabineSIL added a commit that referenced this issue Jul 18, 2024
# This is the 1st commit message:

feat(mac): remove unused func

# This is the commit message #2:

feat(mac): edit, remove unused code

# This is the commit message #3:

feat(mac): more edit

# This is the commit message #4:

feat(mac): comments keymap

# This is the commit message #5:

feat(mac): comments importRules

# This is the commit message #6:

feat(mac): comments

# This is the commit message #7:

feat(mac): more comments

# This is the commit message #8:

feat(mac): adapt data types return para
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants