diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/MTools/Widget/MRadioBouton.pm | 26 | ||||
-rw-r--r-- | src/MTools/Widget/MToggleBouton.pm | 29 |
2 files changed, 35 insertions, 20 deletions
diff --git a/src/MTools/Widget/MRadioBouton.pm b/src/MTools/Widget/MRadioBouton.pm index 768a00d..3491235 100644 --- a/src/MTools/Widget/MRadioBouton.pm +++ b/src/MTools/Widget/MRadioBouton.pm @@ -59,9 +59,15 @@ sub new { plink ([$self, 'text'], [$txt, '-text']); } $self -> mconfigure (-atomic => 1); + + my $timer = new MTools::MTimer (5, 1); + my @gon_tmp = @gon; + push (@gon_tmp, $timer); + my $sw = new MTools::MSwitch ( $self, on => \@gon, + on_tmp => \@gon_tmp, over => \@gover, off => \@goff, ); @@ -73,20 +79,38 @@ sub new { press => [$self, '<Button-1>'], press2 => [$self, 'PRESS'], release => [$self, 'RELEASE'], + timeout => [$timer, 'TIME_OUT'], }, transitions => { on => { enter => { to => 'over', }, + press => { + to => 'off', + notify => 'PRESSED', + }, + press2 => { + to => 'off', + notify => 'PRESSED', + }, + }, + on_tmp => { + press => { + to => 'off', + notify => 'PRESSED', + }, press2 => { to => 'off', notify => 'PRESSED', }, + timeout => { + to => 'on', + }, }, over => { leave => { - to => 'on', + to => 'on_tmp', }, press => { to => 'off', 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'); } } |