I have just done an experiment with my stopwatch touch app.
I have changed my on(touch) handler to clip the xy.x and xy.y values to within the values of 0->g.getWidth() and 0->g.getHeight().
Bangle.on('touch', function(button, xy) {
var x = xy.x;
var y = xy.y;
// adjust for outside the dimension of the screen
if (y > h) { print("y adjusted to h"); y = h; }
if (y < 0) { print("y adjusted to 0"); y = 0; }
if (x > w) { print("x adjusted to w"); x = w; }
if (x < 0) { print("x adjusted to 0"); x = 0; }
etc
Remember when we create buttons we are going to do it on the basis of how wide / high the screen is. So this is on the basis of what is returned from g.getWidth() g.getHeight().
I now find my play button is a lot more responsive near the right edge of the screen.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I have just done an experiment with my
stopwatch touch
app.I have changed my on(touch) handler to clip the xy.x and xy.y values to within the values of 0->g.getWidth() and 0->g.getHeight().
Remember when we create buttons we are going to do it on the basis of how wide / high the screen is. So this is on the basis of what is returned from g.getWidth() g.getHeight().
I now find my play button is a lot more responsive near the right edge of the screen.