AutoClick Feature Demo
Overview
This demo showcases the AutoClick feature available in all StyledComponents buttons and dialogs. AutoClick allows buttons to automatically trigger their Click event after a specified delay.

What You'll Learn
- How to enable AutoClick on buttons
- Setting AutoClickDelay values
- Using AutoClick with different button styles
- AutoClick in TStyledTaskDialog
- Practical use cases for automatic button clicks
AutoClick Buttons
The demo displays three buttons with different styles and AutoClick delays:
Rounded Button
- StyleDrawType:
btRounded - Default Delay: 3000ms (3 seconds)
- Style: Bootstrap Primary
RoundRect Button
- StyleDrawType:
btRoundRect - Default Delay: 5000ms (5 seconds)
- Style: Bootstrap Success
Rectangle Button
- StyleDrawType:
btRect - Default Delay: 7000ms (7 seconds)
- Style: Bootstrap Warning
How It Works
Enabling AutoClick
AutoClickButton.AutoClick := False; // First disable
AutoClickButton.AutoClickDelay := 3000; // Set delay in milliseconds
AutoClickButton.AutoClick := True; // Then enableVisual Countdown
When AutoClick is enabled:
- Button background color is drawn progressively for each second of AutoClickDelay duration.
- Timer counts down to zero
- Click event fires automatically
- OnClick event handler executes
Manual Override
Users can still click the button manually before the delay expires:
- Clicking stops the countdown
- Click event fires immediately
- AutoClick resets if enabled again
Adjustable Delays
The demo includes spin editors to change delays:
- Rounded Button Delay: Adjustable from 1-10 seconds
- RoundRect Button Delay: Adjustable from 1-10 seconds
- Rectangle Button Delay: Adjustable from 1-10 seconds
Click "Start AutoClick" to apply new delays and restart timers.
AutoClick with Dialogs
The demo includes a special section for testing AutoClick with TStyledTaskDialog:
Dialog AutoClick Options
AutoClick Checkbox
Enable/disable automatic dialog closing.
Delay Spin Editor
Set dialog AutoClick delay (default: 5 seconds).
Use Command Links
Toggle between normal buttons and command link style.
Test Dialog Features
The test dialog demonstrates:
- HyperLinks: Clickable links in message text
- File Paths: Links to open files
- Executables: Links to run programs
- Folders: Links to open directories
- Websites: Links to visit URLs
Example dialog message:
LMessage :=
'The file was created: <A HREF="C:\Windows\System32\license.rtf">license.rtf</A>'+sLineBreak+
'You can run: <A HREF="C:\Windows\System32\Notepad.exe">Notepad Editor</A>'+sLineBreak+
'You can open folder: <A HREF="C:\Windows\System32\">C:\Windows\System32\</A>'+sLineBreak+
'You can visit site: <A HREF="http://www.ethea.it">www.Ethea.it</A>';AutoClick Dialog Execution
procedure TfmAutoClick.TestDialogsStyledButtonClick(Sender: TObject);
var
LAutoClickDelay: Integer;
begin
if cbAutoClick.Checked then
LAutoClickDelay := DialogsSpinEdit.Value
else
LAutoClickDelay := -1; // Disable AutoClick
if cbUseCommandLinks.Checked then
DoStyledTaskMessageDlg(
'Dialog Title - use Command Links', LMessage,
TMsgDlgType.mtConfirmation,
[mbAbort, mbRetry, mbIgnore], 0, LAutoClickDelay, True)
else
DoStyledTaskMessageDlg('Dialog Title - use normal Buttons', LMessage,
TMsgDlgType.mtWarning,
[mbOK, mbCancel], 0, LAutoClickDelay, False);
end;Use Cases
1. Countdown Confirmations
Show a confirmation dialog that auto-confirms after a delay:
Btn.Caption := 'Confirm';
Btn.AutoClickDelay := 10000; // 10 seconds
Btn.AutoClick := True;
// User has 10 seconds to cancel2. Auto-Closing Notifications
Information dialogs that close automatically:
StyledTaskDialog.AutoClickDelay := 5000; // 5 seconds
StyledTaskDialog.AutoClick := True;
StyledTaskDialog.Execute;3. Demo/Tutorial Modes
Automated demonstrations:
// Click through demo steps automatically
NextButton.AutoClickDelay := 3000;
NextButton.AutoClick := True;4. Timed Operations
Operations with automatic timeout:
CancelButton.Caption := 'Cancel (30)';
CancelButton.AutoClickDelay := 30000; // 30 seconds
CancelButton.AutoClick := True;Technical Details
AutoClick Properties
| Property | Type | Description |
|---|---|---|
AutoClick | Boolean | Enable/disable automatic clicking |
AutoClickDelay | Integer | Delay in milliseconds before click |
Supported Components
AutoClick is available on:
TStyledButtonTStyledGraphicButtonTStyledBitBtnTStyledSpeedButtonTStyledToolButton(in toolbars)TStyledTaskDialog
Important Notes
- Disable Before Changing: Always set
AutoClick := Falsebefore changing delay - Re-enable After: Set
AutoClick := Trueto restart countdown - OnClick Fires: The OnClick event fires normally when AutoClick triggers
- Manual Override: User can click before delay expires
- Visual Feedback: Caption updates with countdown (configurable)
Source Code Example
procedure TfmAutoClick.StartAutoClick;
begin
// Rounded button - 3 seconds
AutoClickButtonRounded.AutoClick := False;
AutoClickButtonRounded.AutoClickDelay := RoundedSpinEdit.Value;
AutoClickButtonRounded.AutoClick := True;
// RoundRect button - 5 seconds
AutoClickButtonRoundRect.AutoClick := False;
AutoClickButtonRoundRect.AutoClickDelay := RoundRectSpinEdit.Value;
AutoClickButtonRoundRect.AutoClick := True;
// Rect button - 7 seconds
AutoClickButtonRect.AutoClick := False;
AutoClickButtonRect.AutoClickDelay := RectSpinEdit.Value;
AutoClickButtonRect.AutoClick := True;
end;
procedure TfmAutoClick.AutoClick(Sender: TObject);
var
LCaption: string;
begin
LCaption := (Sender as TStyledButton).Caption;
StyledShowMessageFmt('"%s" - Clicked!', [LCaption]);
end;Technical Details
Source Location
Demos/source/AutoClickForm.pas
Supported Versions
All Delphi versions (XE6+)
Initialization
procedure TfmAutoClick.FormCreate(Sender: TObject);
begin
//Initialize Task Dialogs Defaults using Bootstrap buttons:
InitializeStyledTaskDialogs('Bootstrap');
end;See Also
- TStyledButton Reference - Button AutoClick property
- TStyledTaskDialog Reference - Dialog AutoClick feature
