TdxHyperlinkEventArgs.URI Property
Returns the target hyperlink’s URI.
Declaration
property URI: string read;
Property Value
Type | Description |
---|---|
string | The target hyperlink’s URI. |
Remarks
Use Text and URI
properties to identify a hyperlink in a formatted message.
Code Examples
Display Target URIs of Hot-Tracked Hyperlinks in Layout Items
The code example in this section demonstrates OnHyperlinkMouseEnter and OnHyperlinkMouseLeave event handlers that update the form caption as the mouse pointer moves between layout item hyperlinks.
The OnHyperlinkMouseEnter event handler displays the target URI of a hyperlink in the form caption when the mouse pointer enters the hyperlink’s area. The OnHyperlinkMouseLeave event handler changes the form caption to a predefined string when the mouse pointer leaves a hyperlink.
Tip
This scenario can be useful if you need to display hyperlink targets without hints (if the CaptionOptions.ShowHyperlinkHint property is set to bFalse, for example).
procedure TMyForm.dxLayoutControl1Item1HyperlinkMouseEnter(Sender: TObject;
AArgs: TdxHyperlinkEventArgs); // Displays the hyperlink target in the form caption
begin
Caption := 'Navigate to ' + AArgs.URI;
end;
procedure TMyForm.dxLayoutControl1Item1HyperlinkMouseLeave(Sender: TObject;
AArgs: TdxHyperlinkEventArgs); // Displays the predefined string instead of a hyperlink target
begin
Caption := 'Hyperlink Navigation in Layout Item Captions';
end;
Prevent Accidental Hyperlink Activation in Formatted Labels
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;