Pressing buttons in simulator

Former Member
Former Member
I am new to this so sorry if this is a basic question.
How do I press buttons in the Connect IQ Device Simulator?
I am trying to write a simple program for my Forerunner 920xt.
Thanks
  • Put your mouse cursor over the button and click.
  • Put your mouse cursor over the button and click.


    Can't find this working with a Datafield App.
    Was trying to start a Datafield with the Enter Button (FR920XT),
    but info.timerTime only starts when FIT data is simulated.
  • Can't find this working with a Datafield App.

    Data fields can not handle user input. Only widgets and watch-apps have this ability.

    but info.timerTime only starts when FIT data is simulated.

    Yes. On a device it will be non-null after the user starts their activity, and it will stop increasing when the activity is paused.
  • I created a watch app with the default template.
    There is a "Click the menu button" message in the simulator.
    Should a mouse click work for this sample?
  • I created a watch app with the default template.
    There is a "Click the menu button" message in the simulator.
    Should a mouse click work for this sample?


    A mouse click on the menu button, but only there. What target device are you doing the sim with?

    If, for example, you add "vivoactive" as a target, and use that in the sim, click on the 3 lines in the lower right.
  • A mouse click on the menu button, but only there. What target device are you doing the sim with?

    If, for example, you add "vivoactive" as a target, and use that in the sim, click on the 3 lines in the lower right.


    Target Device is FR920XT.
  • If the menu button still isn't working for you it is most likely because you aren't holding the button down long enough. Some devices overload the buttons and holding the button has one behavior while just pressing it has another.

    Travis
  • Just following up on what Travis said, this is true for devices that don't have a dedicated menu button. For example, the fenix 3 (up on press, menu on hold), FR920 (mode on press, menu on hold), or the FR230 (up on press, menu on hold).
  • Former Member
    Former Member over 9 years ago
    onMenu

    My problem was that I was using OnKeyPressed() and it was never going into that code.
    Once i found OnBack and onSelect() I was able to see it work.
    Thanks
  • Former Member
    Former Member over 9 years ago
    Now my problem is this code work in the simulator, but on the Forerunner 920xt, pressing the Back button takes me back to the clock.

    code:

    using Toybox.WatchUi as Ui;
    using Toybox.Graphics as Gfx;

    var testVali = 0;

    class BaseInputDelegate extends Ui.BehaviorDelegate
    {
    function onBack() {
    testVali=testVali-1;
    WatchUi.requestUpdate();
    return true;
    }
    function onSelect() {
    testVali=testVali+1;
    WatchUi.requestUpdate();
    return true;
    }
    }

    class counterView extends Ui.View {

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

    //! Load your resources here
    function onLayout(dc) {
    setLayout(Rez.Layouts.MainLayout(dc));
    }

    //! Called when this View is brought to the foreground. Restore
    //! the state of this View and prepare it to be shown. This includes
    //! loading resources into memory.
    function onShow() {
    }

    //! Update the view
    function onUpdate(dc) {
    dc.setColor( Gfx.COLOR_TRANSPARENT, Gfx.COLOR_BLACK );
    dc.clear();
    dc.setColor( Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT );

    dc.drawText((dc.getWidth() / 2), ((dc.getHeight() / 2) - 30), Gfx.FONT_SMALL, "Counter", Gfx.TEXT_JUSTIFY_CENTER);
    dc.drawText((dc.getWidth() / 2), ((dc.getHeight() / 2) - 10), Gfx.FONT_NUMBER_HOT, testVali.toString(), Gfx.TEXT_JUSTIFY_CENTER);
    }

    //! Called when this View is removed from the screen. Save the
    //! state of this View here. This includes freeing resources from
    //! memory.
    function onHide() {
    }
    }