mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-18 22:37:43 +00:00
fix(web): gesture-model did not check start-item conditions for first source
This commit is contained in:
parent
f23b6e10de
commit
8ca37efcae
1 changed files with 14 additions and 17 deletions
|
|
@ -237,7 +237,7 @@ export class GestureMatcher<Type> implements PredecessorMatch<Type> {
|
|||
return this.predecessor.primaryPath;
|
||||
}
|
||||
|
||||
return bestMatcher.source;
|
||||
return bestMatcher?.source;
|
||||
}
|
||||
|
||||
public get baseItem(): Type {
|
||||
|
|
@ -279,9 +279,19 @@ export class GestureMatcher<Type> implements PredecessorMatch<Type> {
|
|||
throw new Error(`The specified gesture model does not support more than ${existingContacts} contact points.`);
|
||||
}
|
||||
|
||||
// The number of already-active contacts tracked for this gesture
|
||||
const contactSpec = this.model.contacts[existingContacts];
|
||||
this.addContactInternal(simpleSource.constructSubview(false, true));
|
||||
}
|
||||
|
||||
public get result() {
|
||||
return this._result;
|
||||
}
|
||||
|
||||
private addContactInternal(simpleSource: GestureSourceSubview<Type>) {
|
||||
// The number of already-active contacts tracked for this gesture
|
||||
const existingContacts = this.pathMatchers.length;
|
||||
|
||||
const contactSpec = this.model.contacts[existingContacts];
|
||||
const contactModel = new PathMatcher(contactSpec.model, simpleSource);
|
||||
let baseItem: Type = null;
|
||||
if(existingContacts) {
|
||||
// just use the highest-priority item source's base item and call it a day.
|
||||
|
|
@ -303,26 +313,13 @@ export class GestureMatcher<Type> implements PredecessorMatch<Type> {
|
|||
}
|
||||
|
||||
if(contactSpec.model.allowsInitialState) {
|
||||
const initialStateCheck = contactSpec.model.allowsInitialState(simpleSource.currentSample, this.primaryPath.currentSample, baseItem);
|
||||
const initialStateCheck = contactSpec.model.allowsInitialState(simpleSource.currentSample, this.primaryPath?.currentSample, baseItem);
|
||||
|
||||
if(!initialStateCheck) {
|
||||
this.finalize(false, 'path');
|
||||
}
|
||||
}
|
||||
|
||||
this.addContactInternal(simpleSource.constructSubview(false, true));
|
||||
}
|
||||
|
||||
public get result() {
|
||||
return this._result;
|
||||
}
|
||||
|
||||
private addContactInternal(simpleSource: GestureSourceSubview<Type>) {
|
||||
const existingContacts = this.pathMatchers.length;
|
||||
|
||||
// The number of already-active contacts tracked for this gesture
|
||||
const contactSpec = this.model.contacts[existingContacts];
|
||||
const contactModel = new PathMatcher(contactSpec.model, simpleSource);
|
||||
contactModel.promise.then((resolution) => {
|
||||
this.finalize(resolution.type == 'resolve', resolution.cause);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue