Bangle 2 menu and event questions.

Posted on
  • How do you terminate events in Bangle 2? Here's the problem I'm having...

    var menu = {
    	"" : {
    		"title" : " Menu Test"
    	},
    	"Do Nothing" : function() {},
    	"Close Menu" : function() {
    		E.showMenu();
    	}
    };
    
    Bangle.on('touch', function(n,ev) {
    	E.showMenu(menu);
    });
    
    g.clear();
    E.showMenu(menu);
    
    

    After closing the menu there, a tap on the screen opens it again. However, if you tap where the "Close Menu" choice was, the menu promptly closes again. What's the best fix for this?

  • In https://github.com/espruino/BangleApps/b­lob/fb7b69379a61d70bdde176837533e67cd2f6­b288/apps/drinkcounter/app.js#L239 I'm checking the coordinates of the touch. Maybe that would be an approach.

  • I think you only need to remove the touch listener that you introduced on line 11. See my answer on another thread.

    I first learnt that here.

    EDIT: And here's the documentation.

  • Many thanks for the replies. @Ganblejs put me on the right track with listeners. Here's the working code...

    var menu = {
    	"" : {
    		"title" : " Menu Test"
    	},
    	"Do Nothing" : function() {},
    	"Close Menu" : function() {
    		E.showMenu();
    		Bangle.on('touch', screenTouch);
    	}
    };
    
    function screenTouch() {
    	Bangle.removeListener("touch", screenTouch);
    	E.showMenu(menu);
    }
    
    g.clear();
    E.showMenu(menu);
    
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Bangle 2 menu and event questions.

Posted by Avatar for CarlR @CarlR

Actions