diff --git a/apps/draguboard/ChangeLog b/apps/draguboard/ChangeLog index a228aab54..bca1ca7c4 100644 --- a/apps/draguboard/ChangeLog +++ b/apps/draguboard/ChangeLog @@ -1 +1,3 @@ 0.01: New App based on dragboard, but with a U shaped drag area +0.02: 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/draguboard/lib.js b/apps/draguboard/lib.js index 258f8b02d..4500f523a 100644 --- a/apps/draguboard/lib.js +++ b/apps/draguboard/lib.js @@ -104,45 +104,53 @@ exports.input = function(options) { } } + let dragHandlerUB = function(event) { + "ram"; + + // drag on middle bottom rectangle + if (event.x > MIDPADDING - 2 && event.x < (R.x2-MIDPADDING + 2) && event.y >= ( (R.y2) - 12 )) { + moveCharPos(MIDDLE, event.b == 0, (event.x-middleStart)/(middleWidth/MIDDLE.length)); + } + // drag on left or right rectangle + else if (event.y > R.y && (event.x < MIDPADDING-2 || event.x > (R.x2-MIDPADDING + 2))) { + moveCharPos(event.x ( (R.y2) - 52 ))) { + moveCharPos(NUM, event.b == 0, (event.x-NUMPADDING)/6); + } + // Make a space or backspace by tapping right or left on screen above green rectangle + else if (event.y > R.y && event.b == 0) { + if (event.x < (R.x2)/2) { + showChars('<-'); + text = text.slice(0, -1); + } else { + //show space sign + showChars('->'); + text += ' '; + } + prevChar = null; + updateTopString(); + } + }; + + let catchSwipe = (_,__)=>{ + E.stopEventPropagation&&E.stopEventPropagation(); + }; + return new Promise((resolve,reject) => { // Interpret touch input Bangle.setUI({ mode: 'custom', back: ()=>{ Bangle.setUI(); + Bangle.prependListener&&Bangle.removeListener('swipe', catchSwipe); // Remove swipe lister if it was added with `Bangle.prependListener()` (fw2v19 and up). g.clearRect(Bangle.appRect); resolve(text); }, - drag: function(event) { - "ram"; - - // drag on middle bottom rectangle - if (event.x > MIDPADDING - 2 && event.x < (R.x2-MIDPADDING + 2) && event.y >= ( (R.y2) - 12 )) { - moveCharPos(MIDDLE, event.b == 0, (event.x-middleStart)/(middleWidth/MIDDLE.length)); - } - // drag on left or right rectangle - else if (event.y > R.y && (event.x < MIDPADDING-2 || event.x > (R.x2-MIDPADDING + 2))) { - moveCharPos(event.x ( (R.y2) - 52 ))) { - moveCharPos(NUM, event.b == 0, (event.x-NUMPADDING)/6); - } - // Make a space or backspace by tapping right or left on screen above green rectangle - else if (event.y > R.y && event.b == 0) { - if (event.x < (R.x2)/2) { - showChars('<-'); - text = text.slice(0, -1); - } else { - //show space sign - showChars('->'); - text += ' '; - } - prevChar = null; - updateTopString(); - } - } + drag: dragHandlerDB }); + Bangle.prependListener&&Bangle.prependListener('swipe', catchSwipe); // Intercept swipes on fw2v19 and later. Should not break on older firmwares. R = Bangle.appRect; MIDPADDING = R.x + 35; diff --git a/apps/draguboard/metadata.json b/apps/draguboard/metadata.json index dc9b06254..620f39f71 100644 --- a/apps/draguboard/metadata.json +++ b/apps/draguboard/metadata.json @@ -1,6 +1,6 @@ { "id": "draguboard", "name": "DragUboard", - "version":"0.01", + "version":"0.02", "description": "A library for text input via swiping U-shaped keyboard.", "icon": "app.png", "type":"textinput",