aboutsummaryrefslogtreecommitdiff
path: root/src/MTools/Widget/MToggleBouton.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTools/Widget/MToggleBouton.pm')
-rw-r--r--src/MTools/Widget/MToggleBouton.pm29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/MTools/Widget/MToggleBouton.pm b/src/MTools/Widget/MToggleBouton.pm
index ca5415a..cc014f5 100644
--- a/src/MTools/Widget/MToggleBouton.pm
+++ b/src/MTools/Widget/MToggleBouton.pm
@@ -98,7 +98,7 @@ sub new {
my @gon2_tmp = @gon2;
push (@gon2_tmp, $timer);
- my $sw = new MTools::MSwitch (
+ my $sw = $self->{switch} = new MTools::MSwitch (
$self,
'idle1' => \@gon1,
'idle1_tmp' => \@gon1_tmp,
@@ -110,9 +110,6 @@ sub new {
'pressed2' => \@goff2,
);
- $self -> recordEvent ( 'GOTO_STATE_1' );
- $self -> recordEvent ( 'GOTO_STATE_2' );
-
my $st = $self->{states} = new MTools::MState (
current_state => 'idle1',
events => {
@@ -121,8 +118,6 @@ sub new {
enter => [$self, '<Enter>'],
leave => [$self, '<Leave>'],
timeout => [$timer, 'TIME_OUT'],
- to1 => [$self, 'GOTO_STATE_1'],
- to2 => [$self, 'GOTO_STATE_2'],
},
transitions => {
'idle1' => {
@@ -133,9 +128,6 @@ sub new {
to => 'pressed1',
notify => $event1On,
},
- 'to2' => {
- to => 'idle2',
- }
},
'idle1_tmp' => {
'press' => {
@@ -153,7 +145,7 @@ sub new {
},
'leave' => {
to => 'idle1_tmp',
- }
+ },
},
'pressed1' => {
'release' => {
@@ -162,7 +154,7 @@ sub new {
},
'leave' => {
to => 'idle1',
- }
+ },
},
'idle2' => {
'enter' => {
@@ -172,9 +164,6 @@ sub new {
to => 'pressed2',
notify => $event2On,
},
- 'to1' => {
- to => 'idle1',
- }
},
'idle2_tmp' => {
'press' => {
@@ -244,11 +233,13 @@ sub new {
sub changeCurrentState {
my ($self) = @_;
- my $currentState = $self->{states}->mget('state');
- if ($currentState eq 'idle1') {
- $self->notify('GOTO_STATE_2');
- } elsif ($currentState eq 'idle2') {
- $self->notify('GOTO_STATE_1');
+ my $currentState = $self->{switch}->mget('state');
+ if ($currentState =~ /(.*)1(.*)/ ) {
+ $self->{states}->mconfigure('state' => 'idle2');
+ $self->{switch}->mconfigure('state' => 'idle2');
+ } elsif ($currentState =~ /(.*)2(.*)/ ) {
+ $self->{states}->mconfigure('state' => 'idle1');
+ $self->{switch}->mconfigure('state' => 'idle1');
}
}