App from CIQ reboot F3

Former Member
Former Member
I try write a navigation like 'wizard' -> step by -> step, and return to main screen on any break button.
Lets rock:

// first menu simple:
class BaseInputDelegate extends Ui.BehaviorDelegate {
function onMenu() {
var menu = new Ui.Menu();
menu.setTitle("Step one");
menu.addItem( "select 1", :p1 );
menu.addItem( "select 2", :p2 );
Ui.pushView( menu, new MenuInput(), SLIDE_LEFT );
}
}

//second delegate store previous select and play another:

class MenuInput extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if (item.... bla bla // store select one to global variable
var mm = new Ui.Menu();
mm.setTitle("Step two");
mm.addItem( "select 1", :p1 );
mm.addItem( "select 2", :p2 );
Ui.popView(SLIDE_LEFT); // [2]
Ui.pushView( mm, new m1MenuInput(), SLIDE_LEFT );
return true; //we take HANDLE -> I need pernamently close menu 'Step one' before any option or back <- but this not work, menu always back!
// I try set in [2] " Ui.popView(SLIDE_LEFT); " <- this helpfull
}
}

class m1MenuInput extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if (item.... bla bla // store select one to global variable
var mm = new Ui.Menu();
mm.setTitle("Step three");
mm.addItem( "select 1", :p1 );
mm.addItem( "select 2", :p2 );
Ui.popView(SLIDE_LEFT);
Ui.pushView( mm, new m2MenuInput(), SLIDE_LEFT );
return true;
}
}

class m2MenuInput extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if (item.... bla bla // store select one to global variable
var mm = new Ui.Menu();
mm.setTitle("Step four");
mm.addItem( "select 1", :p1 );
mm.addItem( "select 2", :p2 );
Ui.popView(SLIDE_LEFT);
Ui.pushView( mm, new m3MenuInput(), SLIDE_LEFT );
return true;
}
}

.... other pages od wizard


Put this code to widget and try play menu 10-15 times to crash but not IQ! exception but whole system.
  • I agree you should not be able to crash the device. That is definitely a bug.

    Aside from that, if you don't pop the previous view, you need to be sure that it gets popped at some point. Otherwise the view stack gets full and you are holding a bunch of memory that you don't need.

    Aside from that, I'm having a hard time understanding what you are trying to do. If you want to implement a wizard-like interface (Initial -> Page 1 -> Page 2 -> Page 3 -> Done) where you can return to the start page by completing the wizard or you can move back one page by cancelling, it should be pretty easy. You create an input delegate for each step of the wizard. When you reach the last stage of the wizard, you call Ui.popView(Ui.SLIDE_IMMEDIATE) once for each step in the wizard. This will get you out of the wizard and back to the start page. If you want to change views after that, you can call Ui.switchToView() to replace the start view.
  • Also, it is nice if you use and [ /code] tags around your code snippets to maintain formatting.
  • Former Member
    Former Member over 10 years ago
    I'm try popview in point [2]. It's work 'propertly' 3 times ;)

    I think 'linear', not 'stack': create the first menu view, push this on dc, wait for user - always popview if select any option then push next one view.
    I always have the only one view on the stack up to the main. I create next view in delegation from previous.
    Your algoritm build a view on view on view ... and use much more memory.

    I change the code simple.
  • Your algoritm build a view on view on view ... and use much more memory.

    Yes. This has the advantage that it is very easy to go back one step at a time in the wizard by pressing the back/lap button. Assuming your application isn't already low on memory and your views don't take up lots of memory, you should be able to fit a few of them without trouble.

    I _believe_ that you could implement a delegate that would pop the previous menu and push a new one at each step. If you wanted to allow the user to go back to the previous by pressing the back button, you might be able to do so by implementing handleEvent() intercept the back button press, and then pop the current view and push a new view that is the previous menu.

    Travis
  • Former Member
    Former Member over 10 years ago
    Problem is in my delegate.
    pushview get view and delegate, handle screen and push view and delegate to the stack
    When I popview - I destroy youself like this.free() and free view and delegate
    A delegation and a view are 'pair' and they are on the stack - classes handled to the stack not only handled to the screen.
    I'm think that popview simple detach only my view and delegate from 'terminal' - not destroy :)
  • Former Member
    Former Member over 10 years ago
    I'm cure my widget! :) I move all menu pushview's to mainview :)
    But problem with reboot the watch from a ciq app is stil alive.