Skip to content

Instantly share code, notes, and snippets.

@meason
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save meason/85acd363f48d8a4314cd to your computer and use it in GitHub Desktop.

Select an option

Save meason/85acd363f48d8a4314cd to your computer and use it in GitHub Desktop.
Delphi Interceptor Class
{ If you make use of this unit last, the TButton component will be intercepted
and contain the new LastClickTime property }
unit button_interceptor;
interface
uses
stdctrls, sysutils, DateUtils;
type
TButton = class(stdctrls.TButton)
private
fLastClickTime: TDateTime;
public
procedure Click; override;
property LastClickTime : TDateTime read fLastClickTime write fLastClickTime;
end;
implementation
procedure TButton.Click;
const
ClickWaitPeriod = 2;
var
clickTime : TDateTime;
begin
clickTime := Now;
if SecondsBetween(clickTime, LastClickTIme) > ClickWaitPeriod then
inherited
else
Beep;
LastClickTime := clickTime;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment