|
39 | 39 | try{Bangle.buzz(30);}catch(e){}
|
40 | 40 | }
|
41 | 41 | if (mode=="updown") {
|
| 42 | + if (options.drag) throw new Error("Custom drag handler not supported in mode updown!") |
42 | 43 | var dy = 0;
|
43 | 44 | Bangle.dragHandler = e=>{
|
44 | 45 | dy += e.dy;
|
|
52 | 53 | Bangle.on('drag',Bangle.dragHandler);
|
53 | 54 | Bangle.touchHandler = d => {b();cb();};
|
54 | 55 | Bangle.btnWatches = [
|
55 |
| - setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"falling"}), |
| 56 | + setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}), |
56 | 57 | ];
|
57 | 58 | } else if (mode=="leftright") {
|
| 59 | + if (options.drag) throw new Error("Custom drag handler not supported in mode leftright!") |
58 | 60 | var dx = 0;
|
59 | 61 | Bangle.dragHandler = e=>{
|
60 | 62 | dx += e.dx;
|
|
68 | 70 | Bangle.on('drag',Bangle.dragHandler);
|
69 | 71 | Bangle.touchHandler = d => {b();cb();};
|
70 | 72 | Bangle.btnWatches = [
|
71 |
| - setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"falling"}), |
| 73 | + setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}), |
72 | 74 | ];
|
73 | 75 | } else if (mode=="clock") {
|
74 | 76 | Bangle.CLOCK=1;
|
75 | 77 | Bangle.btnWatches = [
|
76 |
| - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"}) |
| 78 | + setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"}) |
77 | 79 | ];
|
78 | 80 | } else if (mode=="clockupdown") {
|
79 | 81 | Bangle.CLOCK=1;
|
|
82 | 84 | b();cb((e.y > 88) ? 1 : -1);
|
83 | 85 | };
|
84 | 86 | Bangle.btnWatches = [
|
85 |
| - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"}) |
| 87 | + setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"}) |
86 | 88 | ];
|
87 | 89 | } else if (mode=="custom") {
|
88 |
| - if (options.clock) Bangle.CLOCK=1; |
89 |
| - if (options.touch) |
90 |
| - Bangle.touchHandler = options.touch; |
91 |
| - if (options.drag) { |
92 |
| - Bangle.dragHandler = options.drag; |
93 |
| - Bangle.on("drag", Bangle.dragHandler); |
94 |
| - } |
95 |
| - if (options.swipe) { |
96 |
| - Bangle.swipeHandler = options.swipe; |
97 |
| - Bangle.on("swipe", Bangle.swipeHandler); |
98 |
| - } |
99 |
| - if (options.btn) { |
100 |
| - Bangle.btnWatches = [ |
101 |
| - setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}) |
102 |
| - ]; |
103 |
| - } else if (options.clock) { |
| 90 | + if (options.clock) { |
104 | 91 | Bangle.btnWatches = [
|
105 |
| - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"}) |
| 92 | + setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"}) |
106 | 93 | ];
|
107 | 94 | }
|
108 | 95 | } else
|
109 | 96 | throw new Error("Unknown UI mode "+E.toJS(mode));
|
| 97 | + if (options.clock) Bangle.CLOCK=1; |
| 98 | + if (options.touch) |
| 99 | + Bangle.touchHandler = options.touch; |
| 100 | + if (options.drag) { |
| 101 | + Bangle.dragHandler = options.drag; |
| 102 | + Bangle.on("drag", Bangle.dragHandler); |
| 103 | + } |
| 104 | + if (options.swipe) { |
| 105 | + Bangle.swipeHandler = options.swipe; |
| 106 | + Bangle.on("swipe", Bangle.swipeHandler); |
| 107 | + } |
| 108 | + if ((options.btn || options.btnRelease) && !Bangle.btnWatches) Bangle.btnWatches = []; |
| 109 | + if (options.btn) Bangle.btnWatches.push(setWatch(options.btn.bind(options), BTN1, {repeat:1,edge:"rising"})) |
| 110 | + if (options.btnRelease) Bangle.btnWatches.push(setWatch(options.btnRelease.bind(options), BTN1, {repeat:1,edge:"falling"})) |
110 | 111 | if (options.remove) // handler for removing the UI (intervals/etc)
|
111 | 112 | Bangle.uiRemove = options.remove;
|
112 | 113 | if (options.redraw) // handler for redrawing the UI
|
|
133 | 134 | btnWatch = setWatch(function() {
|
134 | 135 | btnWatch = undefined;
|
135 | 136 | options.back();
|
136 |
| - }, BTN1, {edge:"falling"}); |
| 137 | + }, BTN1, {edge:"rising"}); |
137 | 138 | WIDGETS = Object.assign({back:{
|
138 | 139 | area:"tl", width:24,
|
139 | 140 | draw:e=>g.reset().setColor("#f00").drawImage(atob("GBiBAAAYAAH/gAf/4A//8B//+D///D///H/P/n+H/n8P/n4f/vwAP/wAP34f/n8P/n+H/n/P/j///D///B//+A//8Af/4AH/gAAYAA=="),e.x,e.y),
|
|
0 commit comments