File tree Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 39
39
jsvObjectIterator is now safe even if not called on something iterable
40
40
X.on now always allocates an array - tidies up code (fix #2559)
41
41
Bangle.js: E.showMenu no longer sends the internal `l` menu object as argument when running the callback function.
42
+ Bangle.js2: Pass the modified touch event on through both E.showScroller and E.showMenu (to enable more complex interaction with menus).
42
43
43
44
2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
44
45
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Original file line number Diff line number Diff line change @@ -5904,6 +5904,10 @@ On Bangle.js there are a few additions over the standard `graphical_menu`:
5904
5904
menu is removed
5905
5905
* (Bangle.js 2) `scroll : int` - an integer specifying how much the initial
5906
5906
menu should be scrolled by
5907
+ * (Bangle.js 2) The mapped functions can consider the touch event that interacted with the entry:
5908
+ `"Entry" : function(touch) { ... }`
5909
+ * This is also true of `onchange` mapped functions in entry objects:
5910
+ `onchange : (value, touch) => { ... }`
5907
5911
* The object returned by `E.showMenu` contains:
5908
5912
* (Bangle.js 2) `scroller` - the object returned by `E.showScroller` -
5909
5913
`scroller.scroll` returns the amount the menu is currently scrolled by
@@ -6046,6 +6050,7 @@ Supply an object containing:
6046
6050
draw : function(idx, rect) { ... }
6047
6051
// a function to call when the item is selected, touch parameter is only relevant
6048
6052
// for Bangle.js 2 and contains the coordinates touched inside the selected item
6053
+ // as well as the type of the touch - see `Bangle.touch`.
6049
6054
select : function(idx, touch) { ... }
6050
6055
// optional function to be called when 'back' is tapped
6051
6056
back : function() { ...}
Original file line number Diff line number Diff line change 133
133
l = g . setFont ( "6x15" ) . wrapString ( title , r . w - pad ) ;
134
134
g . setFontAlign ( - 1 , 0 ) . drawString ( l . join ( "\n" ) , r . x + 12 , r . y + H / 2 ) ;
135
135
} ,
136
- select : function ( idx ) {
136
+ select : function ( idx , touch ) {
137
137
if ( idx < 0 ) return back && back ( ) ; // title
138
138
var item = menu [ keys [ idx ] ] ;
139
139
Bangle . buzz ( 20 ) ;
140
- if ( "function" == typeof item ) item ( ) ;
140
+ if ( "function" == typeof item ) item ( touch ) ;
141
141
else if ( "object" == typeof item ) {
142
- // if a bool, just toggle it
143
142
if ( "number" == typeof item . value ) {
144
143
showSubMenu ( item , keys [ idx ] ) ;
145
144
} else {
145
+ // if a bool, just toggle it
146
146
if ( "boolean" == typeof item . value )
147
147
item . value = ! item . value ;
148
- if ( item . onchange ) item . onchange ( item . value ) ;
148
+ if ( item . onchange ) item . onchange ( item . value , touch ) ;
149
149
if ( l . scroller . isActive ( ) ) l . scroller . drawItem ( idx ) ;
150
150
}
151
151
}
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ Bangle.setUI({
82
82
}
83
83
if ( ( menuScrollMin < 0 || i >= 0 ) && i < options . c ) {
84
84
//console.log("Press ",e.y,i,yInElement);
85
- options . select ( i , { x :e . x , y :yInElement } ) ;
85
+ options . select ( i , { x :e . x , y :yInElement , type : e . type } ) ;
86
86
}
87
87
}
88
88
} ) ;
You can’t perform that action at this time.
0 commit comments