Question

I am making a dialog with a command. This command must close the dialog and go back to the previous form, but it is not working as expected. When I press the command, it closes the dialog but the form do not go back.

I am using the resource editor. State machine controls the app´s navigation.

The code inside the command´s logic is:

dialog.dispose();
StateMachine.back();

Is dispose() the method that I must use to close my dialog?

Thanks for reading.

Était-ce utile?

La solution

As Nirmal said disposing the dialog goes to the previous form so while your call to "back()" works as expected your call to dispose() breaks that logic.

You can override the postShow method for the form you are showing and detect the case of leaving the dialog (just turn on a flag when you need to go back) and call the back method when the form is shown in that condition.

Autres conseils

dont call StateMachine.back() just use dialog.dispose();

There is another solution : try to use the protected void onShowCompleted() method that you must implement in your Form. And declare a boolean variable in your Form ( for example private boolean isDialogShown; ), then in the constructor of your Form set that boolean variable to false, and just before the code of opening the Dialog set its value to true. Then in the code of the protected void onShowCompleted() test if it is true , and if it is true then set it to false and perform the back action : backForm.showBack();

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top