refactor(web): location of lm-engine state-change listener

This commit is contained in:
jahorton 2021-08-24 12:54:11 +07:00
parent e2e7bd4335
commit ffb1f1da02
2 changed files with 15 additions and 18 deletions

View file

@ -54,24 +54,6 @@ namespace com.keyman.osk {
this.loadCookie();
// Predictive-text hooks.
const bannerMgr = this.bannerView;
const _this = this;
// Register a listener for model change events so that we can hot-swap the banner as needed.
// Handled here b/c banner changes may trigger a need to re-layout the OSK.
keymanweb.core.languageProcessor.on('statechange',
function(state: text.prediction.StateChangeEnum) {
let currentType = bannerMgr.activeType;
bannerMgr.selectBanner(state);
if(currentType != bannerMgr.activeType) {
_this.refreshLayout();
}
return true;
});
// Add header element to OSK only for desktop browsers
if(util.device.formFactor == 'desktop') {
const layout = this.desktopLayout = new layouts.TargetedFloatLayout();

View file

@ -76,6 +76,21 @@ namespace com.keyman.osk {
if(deviceSpec.touchable) {
this.setBaseTouchEventListeners();
}
// Register a listener for model change events so that we can hot-swap the banner as needed.
// Handled here b/c banner changes may trigger a need to re-layout the OSK.
const _this = this;
keymanweb.core.languageProcessor.on('statechange',
function(state: text.prediction.StateChangeEnum) {
let currentType = _this.bannerView.activeType;
_this.bannerView.selectBanner(state);
if(currentType != _this.bannerView.activeType) {
_this.bannerView.refreshLayout();
}
return true;
});
}
private setBaseMouseEventListeners() {