aboutsummaryrefslogtreecommitdiff
path: root/src/MTools/Comp/MFocuser.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTools/Comp/MFocuser.pm')
-rw-r--r--src/MTools/Comp/MFocuser.pm23
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)
{