Update lib.js

master
thyttan 2022-05-15 11:52:07 +02:00 committed by GitHub
parent 1b993fb099
commit 4415325703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 13 deletions

View File

@ -25,18 +25,21 @@ exports.input = function(options) {
var caps = true; var caps = true;
var layout; var layout;
function displayText(charTimeout) { function displayText(hideMarker) {
layout.clear(layout.text); layout.clear(layout.text);
layout.text.label = text.slice(settings.showHelpBtn ? -11 : -13) + (charTimeout ? " " : "_"); // Implemented marker here. layout.text.label = text.slice(settings.showHelpBtn ? -11 : -13) + (!hideMarker ? "_" : " ");
layout.render(layout.text); layout.render(layout.text);
} }
function backspace() { function deactivateTimeout(charTimeout) {
// remove the timeout if we had one
if (charTimeout!==undefined) { if (charTimeout!==undefined) {
clearTimeout(charTimeout); clearTimeout(charTimeout);
charTimeout = undefined; charTimeout = undefined;
} }
}
function backspace() {
deactivateTimeout(charTimeout);
text = text.slice(0, -1); text = text.slice(0, -1);
newCharacter(); newCharacter();
} }
@ -56,11 +59,7 @@ exports.input = function(options) {
} }
function onKeyPad(key) { function onKeyPad(key) {
// remove the timeout if we had one deactivateTimeout(charTimeout);
if (charTimeout!==undefined) {
clearTimeout(charTimeout);
charTimeout = undefined;
}
// work out which char was pressed // work out which char was pressed
if (key==charCurrent) { if (key==charCurrent) {
charIndex = (charIndex+1) % letters[charCurrent].length; charIndex = (charIndex+1) % letters[charCurrent].length;
@ -124,7 +123,7 @@ exports.input = function(options) {
]}, ]},
] ]
},{back: ()=>{ },{back: ()=>{
// charTimeout = undefined; // Tried this to see if it would stop the text from being drawn after closing keyboard when doing it too soon after pressing a key. It didn't help. This problem goes back to how I've implemented the marker above. deactivateTimeout(charTimeout);
Bangle.setUI(); Bangle.setUI();
Bangle.removeListener("swipe", onSwipe); Bangle.removeListener("swipe", onSwipe);
g.clearRect(Bangle.appRect); g.clearRect(Bangle.appRect);
@ -140,7 +139,7 @@ exports.input = function(options) {
require('Storage').writeJSON("kbmulti.settings.json", settings); require('Storage').writeJSON("kbmulti.settings.json", settings);
} else { } else {
generateLayout(resolve,reject); generateLayout(resolve,reject);
displayText(true); displayText(false);
Bangle.on('swipe', onSwipe); Bangle.on('swipe', onSwipe);
layout.render(); layout.render();
} }