This trick works for me:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ssDouble in Shift then
begin
if ssLeft in Shift then
ShowMessage('Panel Left Double')
else
ShowMessage('Panel Right Double');
end;
end;
Very simple and clear approach, but still it triggers the Double click after one Mouse down. This will be perfect if you don't care about this one extra mouse down.
silvercoder70, Something like your solution I was thinking to implement(and may be still will go in this direction)
but when I saw your approach Warfley, I started to think that mouse ups are also important in this case.
And even another interesting situation can happen. Double click without release of the button (with hold).
Also, I read that windows by itself is starting timer for double click.
May be the timer solution is good, not to do a lot of empty iterations, combined with proper mouse up handling.
And I can implement it in some base custom control - TMyBaseCustomControl - so all inherited controls can benefit of it.
But if it is implement in LCL by default could be beneficial to all.
I saw this comment in TControl.WndProc - so I see there is that the focus is also involved in the game
It explains also why the mouse down event is sent immediately
LM_LBUTTONDOWN,
LM_LBUTTONDBLCLK:
begin
Include(FControlState, csLButtonDown);
{ The VCL holds up the mouse down for dmAutomatic
and sends it, when it decides, if it is a drag operation or
not.
This decision requires full control of focus and mouse, which
do not all LCL interfaces provide. Therefore the mouse down event
is sent immediately.
Further Note:
Under winapi a LM_LBUTTONDOWN ends the drag immediate.
For example: If we exit here, then mouse down on TTreeView does
not work any longer under gtk.
}
if FDragMode = dmAutomatic then
BeginAutoDrag;
end;
LM_LBUTTONUP:
begin
Exclude(FControlState, csLButtonDown);
end;
end;