IKeyPreviewEventArgs.Cancel

Syntax

Cancel: Boolean;

Description

The Cancel property determines whether the further event that is connected to the keys pressing occurs. If the property is set to True, the further event is canceled.

Example

Executing the example requires a form. Several components that can receive focus are placed on the form. The following procedure is used as a handler of the OnKeyPreview event for all components:

Sub ProcedureOnKeyPreview(Sender: Object; Args: IKeyPreviewEventArgs);

Begin

If Args.Key = Keys.F1 Then

Args.Cancel := True;

End If;

End Sub ProcedureOnKeyPreview;

After executing the example, if the F1 functional key was pressed in the area of any component, when the text was entered, the further events (such as OnKeyDown, OnKeyUp) do not occur.

See also:

IKeyPreviewEventArgs