Skip to main content
All docs
V24.2

TdxHyperlinkClickEventArgs.Handled Property

Specifies if built-in hyperlink activation routines are disabled.

Declaration

property Handled: Boolean read; write;

Property Value

Type Description
Boolean
False
Default. A click on the hyperlink opens its target in the corresponding default application.
True

Built-in hyperlink activation routines are disabled.

Tip

Use this option if you need to prevent hyperlink activation or execute a custom operation instead of hyperlink activation.

Remarks

Set the Handled property to True if you need to prevent hyperlink activation.

Code Examples

The code example in this section demonstrates OnHyperlinkClick and OnCreate event handlers. The OnHyperlinkClick event handler prevents users from activating a hyperlink that contains the MAILTO URI scheme. The OnCreate event handler associates the OnHyperlinkClick event handler with all layout items at startup.

This scenario can be useful if you define layout item captions at runtime.

uses
  System.StrUtils;  // This unit declares the ContainsText global function
// ...

procedure TMyForm.dxLayoutControl1Item1HyperlinkClick(Sender: TObject;
  AArgs: TdxHyperlinkClickEventArgs);
begin
  if ContainsText(AArgs.URI, 'mailto') then  // If the clicked hyperlink contains the "mailto" URI scheme
    AArgs.Handled := True;  // Prevents hyperlink activation
end;

procedure TMyForm.FormCreate(Sender: TObject);  // Associates all layout items with the declared handler
var
  I: Integer;
begin
  for I := 0 to dxLayoutControl1.AbsoluteItemCount - 1 do  // Iterates through all layout items
    dxLayoutControl1.AbsoluteItems[I].OnHyperlinkClick := dxLayoutControl1Item1HyperlinkClick;
end;

The code example in this section demonstrates handlers of OnHyperlinkClick and OnShowHyperlinkHint events. The OnHyperlinkClick event handler requires a user to hold down the Ctrl key to activate a hyperlink. The OnShowHyperlinkHint event handler changes all hyperlink hints to prompt a user to hold the Ctrl key for hyperlink activation.

procedure TMyForm.dxFormattedLabel1PropertiesHyperlinkClick(Sender: TObject;
  AArgs: TdxHyperlinkClickEventArgs);  // Requires the Ctrl key for hyperlink activation
begin
  if AArgs.Shift <> [ssCtrl] then  // If the Ctrl key is not held down
    AArgs.Handled := True;  // Prevents hyperlink activation
end;

procedure TMyForm.dxFormattedLabel1PropertiesShowHyperlinkHint(Sender: TObject;
  AArgs: TdxShowHyperlinkHintEventArgs);  // Changes all hyperlink hints
var
  AHintPrefix, AHintURI: string;
begin
  AHintPrefix := 'Ctrl-click to navigate to ';
  AHintURI := AArgs.URI.Remove(0, 8);  // Removes the URI scheme from the hyperlink hint
  AArgs.Hint := AHintPrefix + AHintURI;  // Redefines the hyperlink hint
end;

VCL Shared Libraries: A Custom Hyperlink Hint

See Also