diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/MTools/Widget/MToggleBouton.pm | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/MTools/Widget/MToggleBouton.pm b/src/MTools/Widget/MToggleBouton.pm index fe598a9..ca5415a 100644 --- a/src/MTools/Widget/MToggleBouton.pm +++ b/src/MTools/Widget/MToggleBouton.pm @@ -110,14 +110,19 @@ sub new { 'pressed2' => \@goff2, ); - my $st = new MTools::MState ( + $self -> recordEvent ( 'GOTO_STATE_1' ); + $self -> recordEvent ( 'GOTO_STATE_2' ); + + my $st = $self->{states} = new MTools::MState ( current_state => 'idle1', events => { press => [$self, '<Button-1>'], release => [$self, '<ButtonRelease-1>'], enter => [$self, '<Enter>'], leave => [$self, '<Leave>'], - timeout => [$timer, 'TIME_OUT'] + timeout => [$timer, 'TIME_OUT'], + to1 => [$self, 'GOTO_STATE_1'], + to2 => [$self, 'GOTO_STATE_2'], }, transitions => { 'idle1' => { @@ -128,6 +133,9 @@ sub new { to => 'pressed1', notify => $event1On, }, + 'to2' => { + to => 'idle2', + } }, 'idle1_tmp' => { 'press' => { @@ -164,6 +172,9 @@ sub new { to => 'pressed2', notify => $event2On, }, + 'to1' => { + to => 'idle1', + } }, 'idle2_tmp' => { 'press' => { @@ -231,6 +242,16 @@ 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'); + } +} + 1; |