Can I close ActionMenu from code?

I open an ActionMenu:

$.menu = new ExitActionMenuView();
WatchUi.showActionMenu($.menu, new ExitActionMenuDelegate());

And when the user takes an action (touch or start or back) then it closes and I do what I need to do.

But there are scenarios when after I opened it I need to close it (let's call it "time out") from code.

On older devices where I used Menu or Menu2 I could pop the view, but ActionMenu is not a View, so neither popView nor switchView to my main view doesn't make the ActionMenu disappear.

Any idea how can I make it disappear (except for not using ActionMenu:) ?

  • I have a feeling that the lack of a way to programmatically close an action menu is intentional on the CIQ team's part.

    I did test a couple of plausible workarounds on fr955 (simulated and real), but both fail on a real device. (SDK 8.4.0, fr955 26.08).

    1) Display the action menu and after a timeout (using Timer.Timer), push a placeholder view which pops itself in onShow().

    This works in the sim but crashes on a real fr955, with a Null Reference error. (Similar to the recently reported action menu bug, except that bug only happens in the sim and not a real device.) The error on the device (as per CIQ_LOG.YML) is:

    Error: Null Reference Error
    Details: 'Failed invoking <symbol>'

    There is no stack trace.

    (In my placeholder view, only initialize() and onShow() are implemented. initialize() only calls the View constructor, and onShow() only calls popView().)

    2a) Display the action menu and after a timeout (using Timer.Timer), just call WatchUi.popView()

    This appears to work in the sim (it doesn't even pop the current view which is "hosting" the action menu), but it crashes on a real fr955 in the same way as above.

    2b) Similar to 2a), but a placeholder view is pushed before the action menu is displayed

    Same kind of crash on real device.

    It's actually strange that 1) crashes, since there shouldn't be a problem doing the same thing in response to user input (in the action menu delegate). Maybe I missed something in my tests.

    Sorry wish I had better news, although maybe you might have better luck if you try a variant of the above methods and investigate a bit more thoroughly than I did.

    EDIT: Also tried the following method, which also crashes on a real device but works in the sim:

    3a) Same as 1 but instead of directly pushing the placeholder view on timeout, set a global flag (with name like "requestCloseActionMenu") to true, call WatchUi.requestUpdate, and push the placeholder view in onUpdate of the current view.

    3b) Same as 3a, but the self-closing placeholder view closes itself on a timer