diff --git a/apps/kbswipe/ChangeLog b/apps/kbswipe/ChangeLog index 38d71986e0..51401deda7 100644 --- a/apps/kbswipe/ChangeLog +++ b/apps/kbswipe/ChangeLog @@ -6,3 +6,5 @@ 0.06: Support input of numbers and uppercase characters. 0.07: Support input of symbols. 0.08: Redone patterns a,e,m,w,z. +0.09: Catch and discard swipe events on fw2v19 and up (as well as some cutting + edge 2v18 ones), allowing compatability with the Back Swipe app. diff --git a/apps/kbswipe/lib.js b/apps/kbswipe/lib.js index 7d05d7a8ea..bed171d724 100644 --- a/apps/kbswipe/lib.js +++ b/apps/kbswipe/lib.js @@ -253,28 +253,38 @@ exports.input = function(options) { }; Bangle.drawWidgets(); + let dragHandlerKB = e=>{ + "ram"; + if (isInside(R, e)) { + if (lastDrag) g.reset().setColor("#f00").drawLine(lastDrag.x,lastDrag.y,e.x,e.y); + lastDrag = e.b ? e : 0; + } + } + + let touchHandlerKB = (n,e) => { + if (WIDGETS.kbswipe && isInside({x: WIDGETS.kbswipe.x, y: WIDGETS.kbswipe.y, w: WIDGETS.kbswipe.width, h: 24}, e)) { + // touch inside widget + cycleInput(); + } else if (isInside(R, e)) { + // touch inside app area + show(); + } + } + + let catchSwipe = ()=>{ + E.stopEventPropagation&&E.stopEventPropagation(); + }; + return new Promise((resolve,reject) => { - Bangle.setUI({mode:"custom", drag:e=>{ - "ram"; - if (isInside(R, e)) { - if (lastDrag) g.reset().setColor("#f00").drawLine(lastDrag.x,lastDrag.y,e.x,e.y); - lastDrag = e.b ? e : 0; - } - },touch:(n,e) => { - if (WIDGETS.kbswipe && isInside({x: WIDGETS.kbswipe.x, y: WIDGETS.kbswipe.y, w: WIDGETS.kbswipe.width, h: 24}, e)) { - // touch inside widget - cycleInput(); - } else if (isInside(R, e)) { - // touch inside app area - show(); - } - }, back:()=>{ + Bangle.setUI({mode:"custom", drag:dragHandlerKB, touch:touchHandlerKB, back:()=>{ delete WIDGETS.kbswipe; Bangle.removeListener("stroke", strokeHandler); + Bangle.prependListener&&Bangle.removeListener('swipe', catchSwipe); // Remove swipe lister if it was added with `Bangle.prependListener()` (fw2v19 and up). if (flashInterval) clearInterval(flashInterval); Bangle.setUI(); g.clearRect(Bangle.appRect); resolve(text); }}); + Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares. }); }; diff --git a/apps/kbswipe/metadata.json b/apps/kbswipe/metadata.json index 3f3fbffa35..22e1e1431a 100644 --- a/apps/kbswipe/metadata.json +++ b/apps/kbswipe/metadata.json @@ -1,6 +1,6 @@ { "id": "kbswipe", "name": "Swipe keyboard", - "version":"0.08", + "version":"0.09", "description": "A library for text input via PalmOS style swipe gestures (beta!)", "icon": "app.png", "type":"textinput",