Skip to content

Commit e2c9d27

Browse files
committed
delete fn
1 parent c684817 commit e2c9d27

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

inputMethods.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,14 @@ namespace microgui {
414414
this.backgroundColor = (opts.backgroundColor) ? opts.backgroundColor : 6; // Default to blue
415415

416416
this.txtColor = (opts.txtColor) ? opts.txtColor : 1;
417-
this.passedDeleteFn = (opts.deleteFn) ? opts.deleteFn : () => { };
417+
this.passedDeleteFn = opts.deleteFn
418418
this.passedBackBtn = (opts.backBtn) ? opts.backBtn : () => { };
419419
}
420420

421421
startup() {
422422
super.startup()
423423

424-
const data = __keyboardLayout(this.keyboardLayout);
424+
const data = __keyboardLayout(this.keyboardLayout, this.passedDeleteFn !== undefined);
425425
this.btns = data.btnTexts.map(_ => []);
426426

427427
const charWidth = bitmaps.font8.charWidth
@@ -532,7 +532,7 @@ namespace microgui {
532532
: (t: string) => { return t.toLowerCase() }
533533

534534

535-
const specialBtnData: SpecialBtnData[] = __keyboardLayout(this.keyboardLayout).specialBtnBehaviours;
535+
const specialBtnData: SpecialBtnData[] = __keyboardLayout(this.keyboardLayout, this.passedDeleteFn !== undefined).specialBtnBehaviours;
536536
const specialBtnRows: number[] = specialBtnData.map((sbd: SpecialBtnData) => sbd.btnRow);
537537
const specialBtnCols: number[] = specialBtnData.map((sbd: SpecialBtnData) => sbd.btnCol);
538538

@@ -553,7 +553,8 @@ namespace microgui {
553553
}
554554

555555
public deleteFn(): void {
556-
this.passedDeleteFn(this.text);
556+
if (this.passedDeleteFn)
557+
this.passedDeleteFn(this.text);
557558
}
558559

559560
public getText() {

0 commit comments

Comments
 (0)