Why can buttons only be clicked once in sim?

I'm making a widget for the Edge 1030 (touch screen) and I'm using the <button behavior="onCustom"> element with a BehaviorDelegate as documented here (https://developer.garmin.com/connect-iq/core-topics/input-handling/). This works fine but only for one tap in the simulator. Any subsequent taps don't seem to call the "behavior" method. Do I need to reset the state of the button somehow after click?

<button x="center" y="90" width="50" height="50" background="Graphics.COLOR_WHITE" behavior="onRefresh">
    <state id="stateDefault" bitmap="@Drawables.DefaultRefreshButton" />
    <state id="stateHighlighted" bitmap="@Drawables.DefaultRefreshButton" />
    <state id="stateSelected" bitmap="@Drawables.DefaultRefreshButton" />
    <state id="stateDisabled" color="Graphics.COLOR_BLACK" />
</button>

class MyButtonDelegate extends WatchUi.BehaviorDelegate {

    function initialize() {
        BehaviorDelegate.initialize();
    }

    function onRefresh() {
        System.println("onRefresh");
        return true;
    }

}

  • Thanks for this. I was actually able to solve it by adding the onSelectable method to my BehaviorDelegate and then return false from the custom behavior method:

    function onSelectable(event) {
        event.getInstance().setState(:stateDefault);
    }
    
    function onPlay() {
        return false;
    }

    <button x="20" y="130" width="111" height="111" behavior="onPlay">

    The only remaining issue for me now is that little menu button in the control bar.

  • The only remaining issue for me now is that little menu button in the control bar.

    I played with a widget from the SDK samples (UserProfile) on a simulated Edge, and now I realize that the point of the menu button is to open the *widget* settings (not system settings), which should've been obvious, in hindsight.

    Since there is no physical "menu" button, I guess Garmin gives you a standard menu button in all cases for CIQ device apps or widgets, just in case your app needs to implement settings (or some other menu-related action).

    The concept of a standard, ubiquitous menu button may not make much sense for a touchscreen Edge, since an app can implement its own menu/settings button, but I'm guessing it exists for parity with non-touchscreen Edges (and maybe even Forerunner watches, although in most cases it probably doesn't really make sense for an app to exist on both platforms.)

    I'm guessing setControlBar() was added at least in part to address this specific case (useless menu button), but it's too bad it only applies to newer Edges.

    I tried modifying the delegate in the UserProfile so onMenu() isn't overridden, but unfortunately that didn't make a difference (although I didn't really expect it to, for various reasons.)

  • Thanks for looking at that! What you say makes sense -- perhaps they'll allow you hide in some future update. For now it doesn't look the best but it doesn't really interfere with the widget's functionality, so not a huge deal. Appreciate your help!