Acknowledged
CIQQA-3719

Action Menu does not work with touch/mouse in the simulator - app crash

If you use an action menu using the device buttons everything seems to work fine. But if you use touch, i.e. click on the menu itself in the simulator with the mouse, the delegate is called, but the action menu is not popped and stays displayed.

This ultimately results in an app crash when you do use the buttons in an attempt to get off the menu:

selected 1

Error: Unexpected Type Error
Stack: 

Encountered app crash.

Thankfully, it all seems to work correctly on a real device, but means it cannot be tested at all on a touch device like the venu 2 or vivoactive 6.

This is broken in SDK 7.1.0 through to 8.4.0. It last worked in 6.2.4

  • Just to make everyone here happy, I added a custom delegate to my recreation code, and I get exactly the same result.

    No matter how I attempt to select an item or exit the menu, I see the same thing:

    - the action menu does not close itself (as the documentation claims it should)

    - the next BACK or ENTER keypress crashes the app. (Pressing UP or DOWN doesn't do anything).

    It doesn't matter whether I use the mouse to simulate a tap, use the mouse to click on a device button, or use the keyboard to simulate the first button press / action.

    However, to trigger the crash, the 2nd action has to be a button press (either via the mouse or keyboard) - simply clicking on the menu item (to simulate a tap) does not cause the crash for me.

    So it does seem that:

    - after the first BACK or ENTER the action menu is in some kind of broken state where it's still on the screen but it's not supposed to be. Again, the docs say: 

    "An action menu will dismiss it self on either user selecting a menu item or pressing back button."

    This isn't happening.

    - the second BACK or ENTER causes the action menu to try to select the item or close itself, but it can't do that because of the previous point

    TL;DR to cause the crash, do the following action twice: press BACK or ENTER.

    class VeryUsefulDelegate extends WatchUi.ActionMenuDelegate {
        function initialize() {
            ActionMenuDelegate.initialize();
        }
    
        function onBack() as Void {
            // this is displayed as expected after the first action, if the first action is BACK
            System.println("onBack"); 
        }
    
        function onSelect(item as WatchUi.ActionMenuItem) as Void {
            // this is displayed as expected after the first action, if the first action is ENTER (or a tap on the menu item)
            System.println("onSelect: " + item); 
        }
    }
    
    class TestView extends WatchUi.View {
    //...
        function onShow() as Void {
            var menu = new ActionMenu(null);
            menu.addItem(new ActionMenuItem({:label => "foo"}, null));
            WatchUi.showActionMenu(menu, new VeryUsefulDelegate());
        }
    //...
    }

    Sample output:

    onBack
    
    Error: Null Reference Error
    Details: Failed invoking <symbol>
    Stack: 
    
    Encountered app crash.

    Again, even if there's something wrong with my code, I don't think the sim should be crashing in this case.

    Environment: fr955, SDK 8.4.0, Windows

  • I only see crashes when using the mouse to select an item by clicking on the item on the screen. Not if I use the mouse to select and enter using the buttons. Maybe try with a custom delegate which has onSelect(). 

    To further my point, why should the use of a non-custom delegate affect the scenario when the user presses BACK to exit the action menu (in the sim)?

    Surely the BACK functionality should work even if there's no custom onSelect() handler?

    Unless the code is somehow written so it crashes / malfunctions on purpose just because I didn't pass in a custom delegate.

    But then again, you pass in a custom delegate and it stiil crashes (just not in all the cases that it crashes for me).

  • Maybe try with a custom delegate which has onSelect(). 

    I'll give it a try later on, when I have a chance

  • How can an action menu do anything with a default delegate? You need at least to have an onSelect() to take some action.

    Just because something doesn't make sense or is impractical, doesn't mean it's incorrect.

    I don't expect the sim to crash because I wrote some code that isn't useful.

  • I only see crashes when using the mouse to select an item by clicking on the item on the screen. Not if I use the mouse to select and enter using the buttons. Maybe try with a custom delegate which has onSelect().