forked from MapComplete/MapComplete
Fixed input for sets (fix #112)
This commit is contained in:
parent
e0f2f70c2e
commit
3653c3ecaa
3 changed files with 34 additions and 30 deletions
|
@ -13,7 +13,8 @@ export default class InputElementMap<T, X> extends InputElement<X> {
|
|||
constructor(inputElement: InputElement<T>,
|
||||
isSame: (x0: X, x1: X) => boolean,
|
||||
toX: (t: T) => X,
|
||||
fromX: (x: X) => T
|
||||
fromX: (x: X) => T,
|
||||
extraSources: UIEventSource<any>[] = []
|
||||
) {
|
||||
super();
|
||||
this.isSame = isSame;
|
||||
|
@ -30,7 +31,7 @@ export default class InputElementMap<T, X> extends InputElement<X> {
|
|||
return currentX;
|
||||
}
|
||||
return newX;
|
||||
}), [], x => {
|
||||
}), extraSources, x => {
|
||||
const newT = fromX(x);
|
||||
return newT;
|
||||
});
|
||||
|
|
|
@ -224,8 +224,22 @@ export class TextField<T> extends InputElement<T> {
|
|||
|
||||
}
|
||||
|
||||
public SetCursorPosition(i: number) {
|
||||
const field = document.getElementById('text-' + this.id);
|
||||
if(field === undefined || field === null){
|
||||
return;
|
||||
}
|
||||
if(i === -1){
|
||||
// @ts-ignore
|
||||
i = field.value.length;
|
||||
}
|
||||
field.focus();
|
||||
// @ts-ignore
|
||||
field.setSelectionRange(i, i);
|
||||
}
|
||||
|
||||
IsValid(t: T): boolean {
|
||||
if(t === undefined || t === null){
|
||||
if (t === undefined || t === null) {
|
||||
return false;
|
||||
}
|
||||
const result = this._toString(t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue