Re:Problems with catching click and double click
On 13 Jan 1998 09:12:29 GMT, alangll...@aol.com (AlanGLLoyd) wrote:
Quote
>>Has anyone an idea how to filter the two onClick events generated at the time
>>that I've got the onDblClick event?
>The only way to do this is to wait after the mouse-down for a short time to see
>if there's a mouse-up within the double-click time limit.
Remember TControl defines a DblClick (among others) procedure which is
designed to handle double left clicks. If you have something you need
to do on the double click event you can simply override the original
DblClick method. Don't forget to call the inherited method :>
here's a very simple example. It's nothing more than a blank form
that, when you double click on it, beeps your computer (I used
MB_ICONQUESTION, but you may use any sound you like. check Delphi help
for information) :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
protected
procedure DblClick; override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.DblClick;
begin
inherited DblClick;
MessageBeep(MB_ICONQUESTION);
end;
end.
Remember, there are two sides to event handling: through the OnXXXX
and through Event Method Override. The OnXXXX property is meant for
the 'end user' to instert needed code to perform wanted actions. The
EMO (Event Method Override) is meant for the component architect to
modify default behavior. When do you use EMO? When there is no OnXXXX
event or when some action must occur before the OnXXXX routine
executes.
jcko...@4dcomm.com
------------------
The following is a brief political announcement. Thank you.