@@ -383,16 +383,17 @@ function showMessagesScroller(msg) {
383383 }
384384 } ) ;
385385
386- // helper function for message selection
387- let findSelectedMsg = function ( scrollIdx ) {
388- for ( let i = firstTitleLinePerMsg . length - 1 ; i >= 0 ; i -- ) {
389- if ( scrollIdx >= firstTitleLinePerMsg [ i ] ) {
390- return MESSAGES [ i ] ;
391- }
392- }
393- }
386+ //// Additional input handling to extend that of E.showScroller ////
387+
388+ // Input handling for positive and negative response via swipes.
389+ // Emits a touch event that in turn triggers the select function of E.showScroller above.
390+ Bangle . swipeHandler = ( lr ) => {
391+ if ( lr ) { Bangle . emit ( "touch" , 1 , { x : Math . floor ( APP_RECT . x2 / 2 ) , y : Math . floor ( APP_RECT . y2 / 2 ) , type : { swipeLR : lr } } ) ; }
392+ } ;
393+ Bangle . on ( "swipe" , Bangle . swipeHandler ) ;
394394
395395 // Add an external back touch handler.
396+ // Emits a new touch event that in turn triggers the select function of E.showScroller above.
396397 let touchHandler = ( button , xy ) => {
397398 // if ((left side of Banlge 1 screen) || (top left corner of Bangle 2 screen))
398399 if ( ( ! xy && 1 === button ) || ( xy && xy . type === 0 && xy . x < 30 && xy . y < 30 ) ) {
@@ -409,6 +410,18 @@ function showMessagesScroller(msg) {
409410 } ;
410411 Bangle . prependListener ( "touch" , touchHandler ) ;
411412
413+ //// Helper functions ////
414+
415+ // helper function for message selection
416+ let findSelectedMsg = function ( scrollIdx ) {
417+ for ( let i = firstTitleLinePerMsg . length - 1 ; i >= 0 ; i -- ) {
418+ if ( scrollIdx >= firstTitleLinePerMsg [ i ] ) {
419+ return MESSAGES [ i ] ;
420+ }
421+ }
422+ }
423+
424+ // Helper function to update new status of messages
412425 function updateReadMessages ( ) {
413426 let shownMsgIdxFirst , shownMsgIdxLast ;
414427 const LINES_PER_SCREEN = APP_RECT . h / FONT_HEIGHT ;
@@ -446,6 +459,8 @@ function showMessagesScroller(msg) {
446459 }
447460 //print(MESSAGES)
448461 }
462+
463+ // Helper functions to handle positive and negative responses to messages
449464 var negHandler , posHandler = [ ] ;
450465 if ( msg . negative ) {
451466 negHandler = ( msg ) => {
@@ -486,10 +501,6 @@ function showMessagesScroller(msg) {
486501 } ;
487502 //footer.push({type:"img",src:atob("QRABAAAAAAAAAAOAAAAABgAAA8AAAAADgAAD4AAAAAHgAAPgAAAAAPgAA+AAAAAAfgAD4///////gAPh///////gA+D///////AD4H//////8cPgAAAAAAPw8+AAAAAAAfB/4AAAAAAA8B/gAAAAAABwB+AAAAAAADAB4AAAAAAAAABgAA=="),col:"#0f0",cb:posHandler});
488503 }
489- Bangle . swipeHandler = ( lr ) => {
490- if ( lr ) { Bangle . emit ( "touch" , 1 , { x :Math . floor ( APP_RECT . x2 / 2 ) , y :Math . floor ( APP_RECT . y2 / 2 ) , type :{ swipeLR :lr } } ) ; }
491- } ;
492- Bangle . on ( "swipe" , Bangle . swipeHandler ) ;
493504}
494505
495506function showMessageSettings ( msg ) {
0 commit comments