Skip to content

removeKeyboards API function validation + enhancement.#395

Merged
jahorton merged 4 commits intomasterfrom
web-5-removeKeyboards-invalid-arg
Nov 6, 2017
Merged

removeKeyboards API function validation + enhancement.#395
jahorton merged 4 commits intomasterfrom
web-5-removeKeyboards-invalid-arg

Conversation

@jahorton
Copy link
Copy Markdown
Contributor

@jahorton jahorton commented Nov 6, 2017

Fixes #5.

Includes code style formatting fix - reviewing the KeymanWeb code component on Github may be easier with the ?w=1 flag.

@jahorton jahorton added this to the P2S7 milestone Nov 6, 2017
console.log("Keyboard '" + sKbd + "' removal success: " + result);
}

// Add keyboard on Enter (as well as pressing button)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy-paste typo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm a big fan of CTRL+C CTRL+V at times...

sKbd=document.getElementById('kbd_id1').value;
kmw.addKeyboards(sKbd);
break;
case 2:
Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems your test page only uses addKeyboard(1)
Were you planning to use this switch statement, or can it be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be; that code is lifted straight from the original uncompiled.html sample page. In case we decide later to reinstate the code, I left it in place.

Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor cleanup on the test page

function removeOnEnter(e)
{
e = e || window.event;
removeKeyboard();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I have the console log open, it seems removeKeyboard() is being called on every keystroke, not just on enter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch there; fixed.

kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lao',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a local /testing/fonts folder?
My chrome console is not finding /testing/fonts/saysettha_web.*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, that issue's been there for quite a while; it's something I've just simply lived with for now. It's straight from the samples-section samplehdr.js file.

Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jahorton jahorton merged commit 84dc897 into master Nov 6, 2017
@jahorton jahorton deleted the web-5-removeKeyboards-invalid-arg branch November 6, 2017 03:34

if(success) {
// Always reset to the first remaining keyboard
keymanweb._SetActiveKeyboard(ss[0]['KI'],ss[0]['KLC'],true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely we should only set active keyboard if the active keyboard was removed?

for(j=ss.length-1; j>=0; j--) {
if('Keyboard_'+arguments[i] == ss[j]['KI'] && ss.length > 1) {
ss.splice(j,1);
success = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that success should reflect all keyboards being removed successfully.

kingsuper195 pushed a commit to kingsuper195/keyman that referenced this pull request Jan 16, 2026
chore: Use bootstrapping from shared-sites 🦭
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

removeKeyboards should not cause an error if the keyboard referenced does not exist

3 participants