Back to Devexpress

TdxHyperlinkClickEvent Type

vcl-cxcontrols-a2be7f58.md

latest6.7 KB
Original Source

TdxHyperlinkClickEvent Type

The procedural type for hyperlink click events in DevExpress controls and their UI elements.

Declaration

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

Parameters

NameTypeDescription
SenderTObject

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

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

Tip

You can call the Sender.ClassType function or use any other RTTI functionality to identify the actual control or UI element type.

| | AArgs | TdxHyperlinkClickEventArgs |

Provides access to information on the hyperlink click event that occurred in the UI element accessible 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. 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.

Accessible Event Parameters

The following parameters are accessible 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:

Formatted Label EditorsThe actual Sender type is TdxFormattedLabel or TdxDBFormattedLabel.Layout ControlSender is a terminal TdxCustomLayoutItem class descendant instance (at the layout item level) or a TdxLayoutControl instance (at the layout control level).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 to identify the clicked mouse button and the state of modifier keys at the moment of event occurrence.

Refer to the TdxHyperlinkClickEventArgs class description for detailed information on all options accessible 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.

delphi
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;
cpp
#include "System.StrUtils.hpp" // Declares the ContainsText global function
// ...

void __fastcall TMyForm::dxLayoutControl1Item1HyperlinkClick(TObject* Sender,
  TdxHyperlinkClickEventArgs *AArgs)
{
  if(ContainsText(AArgs->URI, "mailto")) // If the clicked hyperlink contains the "mailto" URI scheme
    AArgs->Handled = true; // Prevents hyperlink activation
}

void __fastcall TMyForm::FormCreate(TObject *Sender) // Associates all layout items with the declared handler
{
  for(int i = 0; i < dxLayoutControl1->AbsoluteItemCount; i++) // Iterates through all layout items
    dxLayoutControl1->AbsoluteItems[i]->OnHyperlinkClick = dxLayoutControl1Item1HyperlinkClick;
}

Direct TdxHyperlinkClickEvent Type References

The following events reference the TdxHyperlinkClickEvent procedural type:

TdxCustomFormattedLabelProperties.OnHyperlinkClickAllows you to respond to a click on a hyperlink or prevent hyperlink activation.TdxCustomLayoutItem.OnHyperlinkClickAllows you to respond to a click on a hyperlink or prevent hyperlink activation.TdxCustomLayoutControl.OnHyperlinkClickAllows you to respond to a click on a hyperlink in a layout item caption or prevent hyperlink activation. See Also

TdxHyperlinkMouseHoverEvent Procedural Type

TdxShowHyperlinkHintEvent Procedural Type

BBCode-Inspired Text Formatting Markup

cxControls Unit