Home > Software design >  Delphi : losing focus from parent when clicking on child
Delphi : losing focus from parent when clicking on child

Time:01-06

I am having a problem with an effect trigger (shadow effect). I did put the trigger to be ismouseover = true. So, when I put the mouse onto a panel (parent), the shadows activate, and it works fine until I start putting some buttons inside the panel (children).

The shadows effect goes off when the mouse is over the children.

So, is there anyway to keep focus on the parents while being focused on the children?

I did try to change the trigger of the effects (from ismouseover to isfocused), but it didn't give any different results.

CodePudding user response:

As said, your design is wrong, then you can remove the trigger and do it manually :

// show or hide shadow effect
procedure TForm2.ShowShadowEffect(AValue: boolean);
begin
  if ShadowEffect1.Enabled <> AValue then
    ShadowEffect1.Enabled := AValue;
end;

// show when enter on panel
procedure TForm2.Panel1MouseEnter(Sender: TObject);
begin
  ShowShadowEffect(True);
end;

// hide when leave the panel
procedure TForm2.Panel1MouseLeave(Sender: TObject);
begin
  ShowShadowEffect(False);
end;

// keep visible when over button
procedure TForm2.Button1MouseEnter(Sender: TObject);
begin
  ShowShadowEffect(True);
end;
  • Related