diff options
author | caramel | 2007-09-11 12:50:40 +0000 |
---|---|---|
committer | caramel | 2007-09-11 12:50:40 +0000 |
commit | c9c5e72e45bec517b39cd016f80cd57e3f52cf05 (patch) | |
tree | c93bc01312063043f6066a3e50dd3d16e6ea9dbc /src/MTools | |
parent | ae0835f7caea926274e0b53f6425bbe3baae8eb3 (diff) | |
download | mtc-c9c5e72e45bec517b39cd016f80cd57e3f52cf05.zip mtc-c9c5e72e45bec517b39cd016f80cd57e3f52cf05.tar.gz mtc-c9c5e72e45bec517b39cd016f80cd57e3f52cf05.tar.bz2 mtc-c9c5e72e45bec517b39cd016f80cd57e3f52cf05.tar.xz |
Possibilite de changer d un macro etat a l autre
Diffstat (limited to 'src/MTools')
-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; |