4

Is there any way to pop to root window (main window or very first window on stack).

Ex: I have 4 windows say 1,2,3,4. "1" is being my root window and I traverse to 4th window. Now on some action event I want to Jump Back to Window 1 directly.

I went through this pebble documentation , did not get any way to do that.

But this is done in Pebble Default Alarm App, below are the steps:

  1. Set the alarm - (Window 1)
  2. Then after clicking select button it shows some "Menu List" - (Window 2)
  3. Last item in menu list is "Snooze Delay"
  4. Snooze Delay takes user to another Menulist to select snooze time-(Window 3)
  5. After selecting snooze time it shows confirmation message takes user back to alarm screen (Window 1) automatically without user interaction.

Can anyone please provide me pointers on this, how to achieve this behaviour.

iLearner
  • 1,670
  • 2
  • 19
  • 45
  • Can you call `window_stack_pop_all` followed by pushing window 1 back on with `window_stack_push`? The note would seem to indicate this is a supported way of working: _"If there are no windows for the app left on the stack, the app will be killed by the system, shortly. To avoid this, make sure to push another window shortly after or before removing the last window."_ – James Thorpe Oct 09 '15 at 10:14
  • Thanks for quick response, where should I push another window, once I call window_stack_pop_all, Sorry I did not get you. Please elaborate. – iLearner Oct 09 '15 at 10:22
  • I've not worked with the Pebble API (keep meaning to get around to it) so I'm not 100% sure, but it sounds like if you've got a pointer to window 1, you should be able to do: `window_stack_pop_all(false); window_stack_push(win1, false);` – James Thorpe Oct 09 '15 at 10:24
  • @JamesThorpe I tried calling "window_stack_push" in my main windows "deinit()" funtion, after calling "window_stack_pop_all" from my Window 4, it launches app, but then getting closed in 2 sec, i think its crashing but there is no any exception I can see. – iLearner Oct 12 '15 at 07:11
  • I'd do this by having each window call a callback when it closes (in your example, when the user selects the alarm time) and then having this callback cascade (closing all the windows except for the root one) if the event was successful. – humanoid Oct 14 '15 at 19:17

0 Answers0