David Jesus
David Jesus

Reputation: 2111

How to disable back button for certain forms

I want to disable the "back" button on a specific form, but in other forms (views) continue working.

Upvotes: 3

Views: 708

Answers (4)

Spyros
Spyros

Reputation: 339

Another way to do it, is to add a conditional in the Command where the ActionPerformed method of the functional interface ActionListener is implemented.

If the conditions are met, execute the code. In addition you may use an else or else if block to provide user feedback with animateLayout calls.

However, we need to be very careful with this approach, because we do not want to put too much logic in ActionPerformed since it will slow execution, degrading performance.

Upvotes: 0

Don't worry. Just insert an id or class to the concerned form where you need to disable the button. And use that class or id to disable the button.

Ex: Take '#myid button' as selector

Upvotes: -1

Tim Weber
Tim Weber

Reputation: 868

In a specific Form , you can just use inside your Form :

removeCommand(getBackCommand());

Upvotes: 1

Mario Barón
Mario Barón

Reputation: 68

You should override the allowBackTo on the statemachine, this method should return true by default so you can keep going back to other forms but return false for those forms which you do not want to allow going back to, for example, if you want to keep going back to all of your forms with the exception of one called "SplashScreen" you should do the following:

 @Override
    protected boolean allowBackTo(String formName){
        if ("SplashScreen".equals(formName)){
              return false;
            }
            return true;

    }

Upvotes: 2

Related Questions