Know if the mouse is inside TControl with child controls lazarus / 31-LCL ---------------------------------------------------------------------- trexet · 2024-07-04 10:24 Hi. I have several TGroupBox/TPanel containers with buttons and toggleboxes, enabled and disabled. The panels are inside a dynamically created frame, which also has a label at the bottom. I want to set the label caption depending on which panel is hovered and which buttons are enabled, something like a status bar; however, it turned out to be not as easy as I expected: 1) If I use OnMouseEnter/OnMouseLeave for the panels, the OnMouseLeave is triggered when the mouse is hovered over an enabled child control. 2) If I use OnMouseMove for a frame, the behavior is the same: it won't be triggered if the mouse is over any child control, including the panels/boxes I need. 3) Using OnMouseMove for a form does the same. So, which way should I do it, preferably as the frame method? Thanks. ---------------------------------------------------------------------- alpine · 2024-07-04 10:43 Since the child controls are inside the container, perhaps the easiest way is to ignore OnMouseLeave until the cursor position is actually out of the container boundaries. ---------------------------------------------------------------------- jamie · 2024-07-04 10:48 if you look at the "Application" instance which would be the TApplication in the Help file, you can add a OnUserInputHandler. That would be the AddOnUserInput . From there, your receiving event can inspect all messages sent to your application for like Keyboard, Mouse moves etc. You need to familiarize yourself with the basic message handling which are constants found in the LMessages unit. When detecting a desired message you then can use calls like ControlAtPos to determine what control is sitting under the mouse pointer. etc  More on that letter if you need help. ---------------------------------------------------------------------- alpine · 2024-07-04 11:48 Quote from: alpine on July 04, 2024, 12:43:27 pmSince the child controls are inside the container, perhaps the easiest way is to ignore OnMouseLeave until the cursor position is actually out of the container boundaries. That is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls; type  TForm1 = class(TForm)    Button1: TButton;    Panel1: TPanel;    Panel2: TPanel;    procedure Panel1MouseEnter(Sender: TObject);    procedure Panel1MouseLeave(Sender: TObject);  private    procedure ShowInto(AInto: Boolean);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Panel1MouseEnter(Sender: TObject);begin  ShowInto(True);end; procedure TForm1.Panel1MouseLeave(Sender: TObject);var  M: TPoint;begin  M := Panel1.ScreenToClient(Mouse.CursorPos);  if Rect(0, 0, Panel1.Width, Panel1.Height).Contains(M) then    Exit;  ShowInto(False);end; procedure TForm1.ShowInto(AInto: Boolean);begin  if AInto    then Panel2.Color := clGreen    else Panel2.Color := clDefault;end; end. ---------------------------------------------------------------------- Thaddy · 2024-07-04 11:52 What is so difficult in OnMouseEnter and OnMouseLeave??? ---------------------------------------------------------------------- trexet · 2024-07-04 13:19 Quote from: alpine on July 04, 2024, 12:43:27 pmSince the child controls are inside the container, perhaps the easiest way is to ignore OnMouseLeave until the cursor position is actually out of the container boundaries. Thanks, perfectly simple as it should be