mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-10 01:27:43 +00:00
refactor(web): location of lm-engine state-change listener
This commit is contained in:
parent
e2e7bd4335
commit
ffb1f1da02
2 changed files with 15 additions and 18 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue