Simulator and Greyed Out "Force OnShow" "Force OnHide"

SDK is 3.1.7 (was also same on 3.1.6)

On the simulator, the settings portion of the menu, some of the options are greyed out and I'm not sure why?

I would like to test an onHide and onShow on the sim, but seems like this is not enabled for some reason?

Note : It's a datafield and onShow() is supposed to be trigged for a datafield.

  • Is "Force onHide" and "Force onShow" only available to certain apps classes?

    DataField - None of them available

    Widget - looks like Force onHide is available

    Is this interpretation correct? is there any way to simulate when a native Garmin app event occurs? (eg: a native Garmin Auto-Lap screen)

    Trying to figure out what is causing ANT+ disconnection whenever the LAP button is pressed or auto-lap is triggered.

  • For widget watch faces and device apps, if you select Force onHide(), the view gets hidden, but the Force onShow is available

    DF's don't support either call, if I remember correctly.

    If you are in the sim,pressing the "lap" button (often the back button on devices). triggers a lap when you are recording.

    Are you thinking the message is involved, or does the same thing occur if on a real device you move to a different scree/go to the widget loop/etc

  • Hi datafields do support one of them. (Can’t recall onShow or OnHide). 

    withn the Ui.View, if you put a println inside that function, it will get executed once the DF comes back in view. I’m actually using that do do stuffs. 

    anyways, yeah. You’re right. On a real device, pressing lap goes into the native lap screen and during those instance, seems like the ANT+ connection drops out and have to be reconnect. I’m seeing this at every lap (Manual or auto) and I’m trying to figure out why that’s happening. 

    (Note: ANT+ Stryd on a 645M)

  • I'm thinking it's onShow() (I rarely use either).

    Since you got a 645m, see if long pressing the lower left button has the same impact (the music player), or long press the light button (controls).  Or is it very specific to something pushed from laps?

    Are you don't something in onUpdate that should be in compute?

  • actually I don't have a physical 645m or such. I have a Fenix and it works w/o issues. 

    from what I can tell, the connection drops after the user presses LAP button.

    I have tried ANT+ do the connection from ApplicationAppBase.OnStart() as well as Ui.Datafield.Initialise() and both seems to have the same issues.

    I'm now thinking if I should do the connection at compute but this seems a little excessive.

  • datafields do support one of them. (Can’t recall onShow or OnHide). 

    The information you seek is in the WatchUi.View documentation:

    https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/View.html

  • thanks for the link. (I'm already using this instance).

    Hence - is it supposed to be greyed out for the simulator? 

  • A regular view should expect onShow to be called after onLayout but before the first onUpdate, and after a call to onHide; onHide could be called at any time when the view is showing. For a data field, onShow should only get called after onLayout but before the first onUpdate and onHide should never be called.

    Because the data field only gets onShow called when displaying for the first time, it doesn't really make sense to allow the menus to be used to trigger onShow.

    Even if we did allow you to trigger onShow via the menu, we'd only be able to trigger it one time because it does not make sense to call onShow for a data field that is already showing and it does not make sense to make the onHide item available for a data field because this should never be called. If we wanted to do that, we'd almost have to make menu items for the entire life cycle of a view and then only allow you to select the ones that are available based on the current state and type of the view... and i don't think that is a good way to go.

  • Because the data field only gets onShow called when displaying for the first time, it doesn't really make sense to allow the menus to be used to trigger onShow.

    (I don't know how to do quote)

    One of the datafield I have is using the behaviour of onShow to be executed each time the data field is back in the foreground to do some logic.

    function onShow()

      changeSomeSettings()

    }

    the function changeSomeSettings() will get executed each time when the user goes from screen 2 (my data field) to screen 1 and then back to Screen 2(where onShow will get executed)

    Currently, I can only test this functionality on-device and not within the simulator.

  • one more thing is that one can also use this to verify that the data field / app / widget etc are working as expected when it is out of the foreground.

    but of course, what I would really want is an emulator :-)