• Sorry, I should have provided a complete test case to reproduce the behavior but didn't think it was that big of a deal since I found an easy workaround. But since you kindly already went ahead and investigated it, here is code to demonstrate the issue in the Emulator.

    After the menu appears, please click on BTN2 to show the 'data' screen. On the 'data' screen, clicking on BTN2 used to return to the menu, but as you'll see, the menu appears on the mouse button down, and when the mouse button is released, the 'data' screen appears again.

    Hmm... I had naively assumed this was because the watch function was being called on the mouse up and mouse down events, but as you've verified and I see now, there's actually something more going on. Could it be that showMenu is responding to the mouse up event?

    function showMainMenu() {
        E.showMenu();
        
        let menu = {
            '' : {
                'title' : '-- Menu --',
            },
            'Show Data' : function() {
                showDataScreen();
            },
            '< Back' : function() {
    //        '<Back' : function() { // hide red back button
            },
        };
    
        E.showMenu(menu);
    
    }
    
    function showDataScreen() {
        E.showMenu();
        
        setWatch(() => {
            g.clear();
            showMainMenu();
        }, BTN2);
    //    }, BTN2, {edge:'falling'});
    
        displayData();
    }
    
    function displayData() {
        g.clear();
        g.setFont("Vector", 30);
        let title = 'Data';
        g.drawString(title,
                     120 - (g.stringWidth(title) / 2), 40);
    }
    
    showMainMenu();
    

    Oh, I just noticed and remembered something that may be related! With 2v15 on my Bangle 1, there have been times when a BTN2 press on a showMenu doesn't select a menu item. Pressing BTN2 again works as expected so I figured it was a minor hardware issue (though I've never experienced this behavior before 2v15). But the ignored BTN2 press just happened again when I ran the above code on my Bangle 1 and resulted in the same behavior happening in the Emulator. And strangely, I uploaded and ran the code again on my Bangle 1, and this time showMenu responded to the first BTN2 press and the code worked as intended (i.e., pressing BTN2 while on the 'data' screen didn't briefly show the menu and unexpectedly return to the 'data' screen).

    Well suddenly this got a lot more interesting! Thank you in advance for looking into this and I hope you'll be able to reproduce and resolve the inconsistent behavior on the Bangle 1.

About

Avatar for TTBangler @TTBangler started