vcl-cxcontrols-f213f9e6.md
Stores information on a hyperlink click event in a DevExpress control or its UI element.
TdxHyperlinkClickEventArgs = class(
TdxHyperlinkEventArgs
)
Hyperlink click events allow you to modify hyperlink activation behavior in DevExpress controls and their UI elements.
The list below outlines key members of the TdxHyperlinkClickEventArgs class. These members allow you to identify the target hyperlink and its parent UI element as well as prevent a user from activating the hyperlink.
Button | ShiftAllow you to identify the clicked mouse button and the state of modifier keys at the moment of event occurrence.HandledAllows you to prevent hyperlink activation.HyperlinkIndexReturns the index of the target hyperlink in the parent UI element’s message.ItemProvides access to the parent UI element of the target hyperlink.TextReturns the target hyperlink’s anchor text.URIAllows you to identify the hyperlink’s target URI and change it.
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;
#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;
}
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;
void __fastcall TMyForm::dxFormattedLabel1PropertiesHyperlinkClick(TObject *Sender,
TdxHyperlinkClickEventArgs *AArgs) // Requires the Ctrl key for hyperlink activation
{
if(AArgs->Shift != (TShiftState() << [ssCtrl])) // If the Ctrl key is not held down
AArgs->Handled = true; // Prevents hyperlink activation
}
void __fastcall TMyForm::dxFormattedLabel1PropertiesShowHyperlinkHint(TObject *Sender,
TdxShowHyperlinkHintEventArgs *AArgs) // Changes all hyperlink hints
{
UnicodeString AHintPrefix, AHintURI;
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
}
The TdxHyperlinkClickEvent procedural type references a TdxHyperlinkClickEventArgs object as the AArgs parameter.
TObject TdxEventArgs TdxHyperlinkEventArgs TdxHyperlinkClickEventArgs
See Also
TdxShowHyperlinkHintEventArgs Class
BBCode-Inspired Text Formatting Markup