Author Topic: [solved] OnMouseLeave in a TCheckListBox  (Read 1667 times)


  • Jr. Member
  • **
  • Posts: 99
[solved] OnMouseLeave in a TCheckListBox
« on: January 11, 2022, 07:42:04 pm »
I'm looking at onMouseLeave to see if it solves some some display issues for TCheckListBoxes that I'm using, but I'm doing something stupid.

Method is defined as:
Code: Pascal  [Select][+][-]
  1. procedure TBasePanel.MouseLeave(Sender: TObject);
  2. begin
  3.   writeln('left a box');
  4. end;

In the constructor for TBasePanel I have:
Code: Pascal  [Select][+][-]
  1. Box1:= TFoxCheckBox.Create(Self);
  2.   with Box1 do begin
  3.       other stuff...
  4.       OnMouseMove:= @DriveHint;
  5.       OnMouseLeave:= @MouseLeave;
  6.   end;
but I'm getting a compile error on @MouseLeave:
basepanel.pas(211,23) Error: Incompatible types: got "<procedure variable type of procedure of object;Register>" expected "<procedure variable type of procedure(TObject) of object;Register>"

Not obvious to me what I'm doing wrong?
« Last Edit: January 11, 2022, 11:55:27 pm by andyH »


  • Hero Member
  • *****
  • Posts: 3984
Re: OnMouseLeave in a TCheckListBox
« Reply #1 on: January 11, 2022, 09:41:35 pm »
MouseLeave is a protected method of TControl (and so of TBasePanel).
You have a name conflict. {$Mode objfpc} is designed to highlight exactly such ambiguities in your code.
Rename your onmouseleave method to something different from an already declared method name.


  • Jr. Member
  • **
  • Posts: 99
Re: OnMouseLeave in a TCheckListBox
« Reply #2 on: January 11, 2022, 11:55:06 pm »
Thanks, changed the name, compiles. I wish all my problems were that easily solved.


TinyPortal © 2005-2018