From 5add44e915c4268c90246a6cc8fc987da3874a72 Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 4 Jul 2022 08:54:52 +0700 Subject: [PATCH 1/2] fix(web): properly binds 'suggestionApplied' event handler --- web/source/osk/banner.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/source/osk/banner.ts b/web/source/osk/banner.ts index 8bd2b83356..f35b3269b7 100644 --- a/web/source/osk/banner.ts +++ b/web/source/osk/banner.ts @@ -393,13 +393,15 @@ namespace com.keyman.osk { keyman.core.languageProcessor.addListener('suggestionapplied', this.suggestionApplied); } + // tryRevert: () => boolean = function(this: SuggestionManager, returnObj: {shouldSwallow: boolean}) { + /** * Handler for post-processing once a suggestion has been applied: calls * into the active keyboard's `begin postKeystroke` entry point. * @param outputTarget * @returns true */ - suggestionApplied(outputTarget: text.OutputTarget): boolean { + suggestionApplied: (outputTarget: text.OutputTarget) => boolean = function(this: SuggestionBanner, outputTarget: text.OutputTarget) { const keyman = com.keyman.singleton; // Tell the keyboard that the current layer has not changed keyman.core.keyboardProcessor.newLayerStore.set(''); @@ -411,7 +413,7 @@ namespace com.keyman.osk { ?.finalize(keyman.core.keyboardProcessor, outputTarget, true); return true; - }; + }.bind(this); postConfigure() { let keyman = com.keyman.singleton; @@ -427,6 +429,7 @@ namespace com.keyman.osk { keyman.core.languageProcessor.removeListener('suggestionsready', manager.updateSuggestions); keyman.core.languageProcessor.removeListener('tryaccept', manager.tryAccept); keyman.core.languageProcessor.removeListener('tryrevert', manager.tryRevert); + keyman.core.languageProcessor.removeListener('suggestionapplied', this.suggestionApplied); } } From e65656f3c3673eb8f06a340691427fcc3ab68660 Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 4 Jul 2022 09:00:07 +0700 Subject: [PATCH 2/2] chore(web): cleanup --- web/source/osk/banner.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/source/osk/banner.ts b/web/source/osk/banner.ts index f35b3269b7..e71a2e8f32 100644 --- a/web/source/osk/banner.ts +++ b/web/source/osk/banner.ts @@ -393,8 +393,6 @@ namespace com.keyman.osk { keyman.core.languageProcessor.addListener('suggestionapplied', this.suggestionApplied); } - // tryRevert: () => boolean = function(this: SuggestionManager, returnObj: {shouldSwallow: boolean}) { - /** * Handler for post-processing once a suggestion has been applied: calls * into the active keyboard's `begin postKeystroke` entry point.