Skip to main content
All docs
V25.1
  • TdxCustomLayoutControl.OnHyperlinkClick Event

    Allows you to respond to a click on a hyperlink in a layout item caption or prevent hyperlink activation.

    Declaration

    property OnHyperlinkClick: TdxHyperlinkClickEvent read; write;

    Remarks

    A click on a hyperlink defined as a part of a formatted layout item caption invokes the default application associated with the hyperlink’s URI scheme (a browser for HTTP/HTTPS, a mail client for MAILTO, etc.)

    You can handle the OnHyperlinkClick event to execute custom code in response to a click on a hyperlink in a layout item’s caption or prevent hyperlink activation depending on certain conditions in your application.

    Layout Control and Layout Item Events

    The OnHyperlinkClick event allows you to implement a common hyperlink click handler for all layout items in the control. Alternatively, you can handle the OnHyperlinkClick event of individual layout items.

    Event Occurrence

    The OnHyperlinkClick event occurs every time a user clicks a hyperlink in a layout item caption.

    Event Parameters

    The following parameters are accessible within an OnHyperlinkClick event handler:

    Sender
    Provides access to the layout control that raised the hyperlink click event.
    AArgs
    Provides access to information related to the hyperlink click event that occurred and allows you to prevent hyperlink activation. You can use AArgs.Button and AArgs.Shift properties to identify the clicked button and the state of modifier keys at the moment of event occurrence.

    Refer to TdxHyperlinkClickEvent and TdxHyperlinkClickEventArgs type descriptions for detailed information on all options available within an OnHyperlinkClick event handler.

    The code example in this section demonstrates OnHyperlinkClick and OnShowHyperlinkHint event handlers. The OnHyperlinkClick 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.dxLayoutControl1HyperlinkClick(Sender: TObject;
      AArgs: TdxHyperlinkClickEventArgs);
    begin
      if AArgs.Shift <> [ssCtrl] then  // If the Ctrl key is not held down
        AArgs.Handled := True; // Prevents hyperlink activation
    end;
    
    procedure TMyForm.dxLayoutControl1ShowHyperlinkHint(Sender: TObject;
      AArgs: TdxShowHyperlinkHintEventArgs);
    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;
    
    See Also