Last active
August 29, 2015 14:13
-
-
Save meason/85acd363f48d8a4314cd to your computer and use it in GitHub Desktop.
Delphi Interceptor Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { 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