Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizard 'Back' button does not return to previous step #3887

Open
gusmanb opened this issue Dec 15, 2024 · 1 comment
Open

Wizard 'Back' button does not return to previous step #3887

gusmanb opened this issue Dec 15, 2024 · 1 comment
Labels

Comments

@gusmanb
Copy link

gusmanb commented Dec 15, 2024

Describe the bug
Wizard 'Back' button does not return to previous step.

To Reproduce
This simple case illustrates the problem:

using Terminal.Gui;
using TerminalCapture;

Application.Init();
Wizard wizard = new Wizard();
wizard.AddStep(new WizardStep());
wizard.AddStep(new WizardStep());
Application.Run(wizard);

When in the second step press the back button, it stays in the same step.

Debugging the code it seems the back button in fact goes back but it instantly goes to the next step, adding a handler to the MovingNext event makes it obvious as it triggers immediatelly and if you cancel the event it stays properly in the correct step.

Expected behavior
Wizard moves back to the previous step and stays in it.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version v2_develop
@gusmanb gusmanb added the bug label Dec 15, 2024
@gusmanb
Copy link
Author

gusmanb commented Dec 15, 2024

A simple workaround that demonstrates that the problem is that 'GoNext()' is called right after 'GoBack()'.

using Terminal.Gui;
using TerminalCapture;

Application.Init();
Wizard wizard = new CanGoBackWizard();
wizard.AddStep(new WizardStep());
wizard.AddStep(new WizardStep());
Application.Run(wizard);

class CanGoBackWizard : Wizard
{

    private bool _back;

    public CanGoBackWizard()
    {
        MovingNext += CanGoBackWizard_MovingNext;
        MovingBack += CanGoBackWizard_MovingBack;
    }

    private void CanGoBackWizard_MovingBack(object? sender, WizardButtonEventArgs e)
    {
        _back = true;
    }

    private void CanGoBackWizard_MovingNext(object? sender, WizardButtonEventArgs e)
    {
        if (_back)
        {
            _back = false;
            e.Cancel = true;
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant