diff options
Diffstat (limited to 'src/MTools')
-rw-r--r-- | src/MTools/Widget/MToggleBouton.pm | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/src/MTools/Widget/MToggleBouton.pm b/src/MTools/Widget/MToggleBouton.pm index d10170d..31f9780 100644 --- a/src/MTools/Widget/MToggleBouton.pm +++ b/src/MTools/Widget/MToggleBouton.pm @@ -45,11 +45,15 @@ sub new { my $over2 = defined $options {g_over2} ? minstance ($options {g_over2}, $self) : $on2; my $event1On = defined $options {e_press1} ? $options {e_press1} : 'PRESS1'; - my $event1Off = defined $options {e_release1} ? $options {e_release1} : 'RELEASED1'; + my $event1Off = defined $options {e_release1} ? $options {e_release1} : 'RELEASE1'; my $event2On = defined $options {e_press2} ? $options {e_press2} : 'PRESS2'; - my $event2Off = defined $options {e_release2} ? $options {e_release2} : 'RELEASED2'; + my $event2Off = defined $options {e_release2} ? $options {e_release2} : 'RELEASE2'; # my $cb = $options {call} if (defined $options {call}); + $self -> recordEvent ('TOGGLE'); + $self -> recordEvent ('FORCE_PRESS'); + $self -> recordEvent ('FORCE_RELEASE'); + my @gon1; push (@gon1, $on1); my @goff1; @@ -117,7 +121,11 @@ sub new { release => [$self, '<ButtonRelease-1>'], enter => [$self, '<Enter>'], leave => [$self, '<Leave>'], - timeout => [$timer, 'TIME_OUT'], + toggle => [$self, 'TOGGLE'], + frelease => [$self, 'FORCE_RELEASE'], + fpress => [$self, 'FORCE_PRESS'], + timeout => [$timer, 'TIME_OUT'] + }, transitions => { 'idle1' => { @@ -128,12 +136,24 @@ sub new { to => 'pressed1', notify => $event1On, }, + 'toggle' => { + to => 'idle2', + }, + 'fpress' => { + to => 'idle2', + }, }, 'idle1_tmp' => { 'press' => { to => 'pressed1', notify => $event1On, }, + 'toggle' => { + to => 'idle2', + }, + 'fpress' => { + to => 'idle2', + }, 'timeout' => { to => 'idle1', }, @@ -143,6 +163,12 @@ sub new { to => 'pressed1', notify => $event1On, }, + 'toggle' => { + to => 'idle2', + }, + 'fpress' => { + to => 'idle2', + }, 'leave' => { to => 'idle1_tmp', }, @@ -152,6 +178,12 @@ sub new { to => 'hover2', notify => $event1Off, }, + 'toggle' => { + to => 'idle2', + }, + 'fpress' => { + to => 'idle2', + }, 'leave' => { to => 'idle1', }, @@ -160,6 +192,12 @@ sub new { 'enter' => { to => 'hover2', }, + 'toggle' => { + to => 'idle1', + }, + 'frelease' => { + to => 'idle1', + }, 'press' => { to => 'pressed2', notify => $event2On, @@ -170,6 +208,12 @@ sub new { to => 'pressed2', notify => $event2On, }, + 'toggle' => { + to => 'idle1', + }, + 'frelease' => { + to => 'idle1', + }, 'timeout' => { to => 'idle2', }, @@ -179,6 +223,12 @@ sub new { to => 'pressed2', notify => $event2On, }, + 'toggle' => { + to => 'idle1', + }, + 'frelease' => { + to => 'idle1', + }, 'leave' => { to => 'idle2_tmp', } @@ -188,6 +238,12 @@ sub new { to => 'hover1', notify => $event2Off, }, + 'toggle' => { + to => 'idle1', + }, + 'frelease' => { + to => 'idle1', + }, 'leave' => { to => 'idle2', } @@ -230,6 +286,10 @@ sub new { return $self; } +sub isDown { + my ($self) = @_; + return $self -> {states} -> mget ('state') eq 'idle2'; +} sub changeCurrentState { my ($self) = @_; |