#!/usr/bin/perl
$|=1;
use strict;
# a CDialog lib copy in local example folder
use lib '../lib',
'lib';
our $objA = Local::UsecaseA->new();
my $tree = {
title => 'Conditinal behaviour',
entries => [
{
title => 'entry A (prework for B)',
function => \&doA,
condition => undef,
},
{
title => 'entry B',
function => \&doB,
condition => sub{ $objA->check() },
},
{
title => 'reset A (undo prework)',
function => \&resetA,
condition => sub{ $objA->check() },
},
],
};
my $menu_control = UI::Dialog::Util::MenuControl->new( menu => $tree );
$menu_control->run();
exit;
sub doA{
print "doing A\n";
$objA->{"a_called"} = 1;
return;
}
sub doB{
print "doing B\n";
return;
}
sub resetA{
$objA->{"a_called"} = 0;
return;
}
##################################
sub new{
return bless {}, shift;
}
sub check{
my $self = shift;
return $self->{"a_called"};
}
1;