diff options
author | merlin | 2007-11-26 08:49:36 +0000 |
---|---|---|
committer | merlin | 2007-11-26 08:49:36 +0000 |
commit | 3a88ad93c9165176b292d10afd0c271303f5538f (patch) | |
tree | 3057e0355a9a4ad0a48d27c3af63d1f4359afe94 /src | |
parent | 446d1862e1502d307dd9b9a76aa51d786001dfb5 (diff) | |
download | mtc-3a88ad93c9165176b292d10afd0c271303f5538f.zip mtc-3a88ad93c9165176b292d10afd0c271303f5538f.tar.gz mtc-3a88ad93c9165176b292d10afd0c271303f5538f.tar.bz2 mtc-3a88ad93c9165176b292d10afd0c271303f5538f.tar.xz |
Ajout de la possibilite de supprimer un element du mfocuser
Diffstat (limited to 'src')
-rw-r--r-- | src/MTools/Comp/MFocuser.pm | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/MTools/Comp/MFocuser.pm b/src/MTools/Comp/MFocuser.pm index 7d984da..91afd48 100644 --- a/src/MTools/Comp/MFocuser.pm +++ b/src/MTools/Comp/MFocuser.pm @@ -41,10 +41,13 @@ sub new { my $self = new MTools::MObjet (); bless $self, $class; + $self -> recordProperty (focused => undef); $self -> recordEvent ('GET_FOCUS'); $self -> recordEvent ('SET_FOCUS'); - - $self -> {__targets} = \@targets; + if (defined @targets) + { + $self -> {__targets} = \@targets; + } for (my $i; $i < @targets; $i++) { $targets [$i] -> binding ('GET_FOCUS', ['setFocused', $self]); @@ -61,12 +64,26 @@ sub add { $tg -> binding ('GET_FOCUS', ['setFocused', $self]); } +sub remove { + my ($self, $tg) = @_; + if (!defined $self -> {__targets}) {return;} + my @tgs = @{$self -> {__targets}}; + for (my $i = 0; $i < @tgs; $i++) + { + if ($tgs [$i] == $tg) { + splice (@{$self -> {__targets}}, $i, 1); + return; + } + } +} + sub setFocused { my ($self, $tg) = @_; + $self -> mconfigure (focused => $tg); if (!defined $self -> {__targets}) {return;} my @tgs = @{$self -> {__targets}}; my $from_children = 0; - for (my $i; $i < @tgs; $i++) + for (my $i = 0; $i < @tgs; $i++) { if ($tgs [$i] ne $tg) { |