Back to Devexpress

TdxHyperlinkClickEventArgs.Shift Property

vcl-cxcontrols-dot-tdxhyperlinkclickeventargs-b1fa2d4e.md

latest3.6 KB
Original Source

TdxHyperlinkClickEventArgs.Shift Property

Returns the state of modifier keys when the target hyperlink was clicked.

Declaration

delphi
property Shift: TShiftState read;

Property Value

TypeDescription
TShiftState

The state of modifier keys when the target hyperlink was clicked.

|

Remarks

Use Button and Shift properties to identify how a user clicked the target hyperlink. These properties can be useful if you need to change the predefined hyperlink activation method. For example, you can add any combination of modifier keys as a requirement to prevent accidental hyperlink activation.

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.

delphi
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;
cpp
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
}

See Also

TdxHyperlinkClickEventArgs.Handled Property

TdxHyperlinkClickEventArgs.URI Property

TdxHyperlinkClickEventArgs Class

TdxHyperlinkClickEventArgs Members

cxControls Unit