onNextPage() always closes widget

Dear Developers,

If you can please help. I believe I am doing sth wrong at very basic level, as I cannot find any help about it in the previous threads…

Whenever onNextPage() or onPreviousPage() in Delegate is called, after performing whatever this function was designed to do, widget closes the simulation (I am getting blue triangle there and „completed” on the console, so I guess it is closing). I tried returning flase or true or nothing at all form those methods but effect is always the same — simulation closes after pressing „up” or „down” button.

Would you have any idea what am I possibly doing wrong?

Thanks!
Drewniacki
  • On the main view in a widget, up/down are used to move through the widget loop, so when you do an up/down in the sim on the main view, the widget exits.

    You need to push a second view, and then do up/down in that view's delegate.
  • So a basic flow could be:

    Start with your main view (maybe a summary). When the user presses start, or takes some other action, push the second view where up/down can be used. In the second view, "back" returns to the first view, where up/down are used for the widget loop.
  • Thanks, Jim. Sorry, I didn't specify - it happens on a view pushed from the main view.

    So as you say, when widget opens, I press start and that pushes second view. On this second view whenever I press up or down simulator closes. Even if I define onBack() on the second view to push back the main view I can see that main view opens for a split second and then simulator closes. Again - that happens regardless of what those functions return: true, false or nothing at all.

    Do I have to tell somehow to the watch that this second view is not a main view, maybe? For now I only call BehaviorDelegate.initialize() in initialize method of my second view's delegate
  • In the delegate in the second view, try catching up/down and return true.
  • Okay, I found my mistake. As I just copied it from one of the samples, I was using switchToView() from main view delegate, which pushes new view but also pops current one (hence — making new view the main one). Instead I should have been using pushView(). Changed that and it solved the issue.

    Thanks for your help!