Skip to main content
All docs
V26.1
  • TdxHyperlinkClickEvent Type

    The procedural type for hyperlink click events in DevExpress controls with support for BBCode-inspired text formatting markup.

    Declaration

    TdxHyperlinkClickEvent = procedure(Sender: TObject; AArgs: TdxHyperlinkClickEventArgs) of object;

    Parameters

    Name Type Description
    Sender TObject

    Provides access to the control or UI element that raised the event.

    Cast this parameter value to the corresponding terminal control or UI element class to access its public API members. Refer to the following section for detailed information on Sender types in different DevExpress products: Available Event Parameters.

    Tip

    Call the Sender.ClassType function or use other RTTI functionality to identify the actual control or UI element type.

    AArgs TdxHyperlinkClickEventArgs

    Contains information about the event raised by the UI element available through the Sender parameter.

    For example, you can set the AArgs.Handled property to True to prevent hyperlink activation.

    Remarks

    You can handle this event to implement a custom response to a click on a hyperlink defined in a formatted message, label, or UI element caption in a DevExpress control with support for BBCode-inspired text formatting markup. For example, you can prevent users from activating certain hyperlinks or execute custom code in response to a click on a hyperlink.

    Event Occurrence

    This event occurs every time a user clicks a hyperlink defined in a formatted message, label, or UI element caption.

    Available Event Parameters

    The following parameters are available within a hyperlink click event:

    Sender

    Provides access to the control or UI element that raised the hyperlink click event. The Sender parameter type depends on the class that declares the corresponding OnHyperlinkClick event:

    AArgs

    Contains information about the hyperlink click event that occurred and allows you to prevent hyperlink activation. You can use AArgs.Button and AArgs.Shift to identify the clicked mouse button and modified keys help while the button is clicked.

    Refer to the TdxHyperlinkClickEventArgs class description for detailed information on all options available within a hyperlink click event handler.

    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;  // 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;
    

    Direct Type References

    The TdxFormattedTextPropertiesBase.OnHyperlinkClick event references the TdxHyperlinkClickEvent procedural type.

    See Also