I'm trying to create a custom button out of a TPanel component. For this, I have provided an override for the onmousedown and onmouseup events (to do some drawing), and I've used the onclick event to handle the clicks.
Unfortunately, if I rapidly click my panel, every other click is "lost", but I can't figure out why.
Even the easiest of examples fails in this regard. I created a new VCL application, added a listbox, one panel, and implemented the events as follows:
procedure TForm1.Panel1Click(Sender: TObject);
begin
listbox1.Items.Add('click');
end;
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
listbox1.Items.Add('mouse down');
end;
procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
listbox1.Items.Add('mouse up');
end;
The result is as follows:
mouse down
click
mouse up
mouse down
mouse up
etcetera... Each second click is disregarded, but I have no idea why.
Can anybody explain this please?