[Overview][Classes][Procedures and functions][Index] Reference for unit 'Spin' (#lcl)

TCustomFloatSpinEdit.KeyPress

Handles key press events for the control.

Declaration

Source position: spin.pp line 70

protected procedure TCustomFloatSpinEdit.KeyPress(

  var Key: Char

); override;

Arguments

Key

  

Character value for the key press event.

Description

KeyPress is an overridden method used to handle key press events for the control. KeyPress calls the inherited method on entry. If the character in Key is not handled in the ancestor class, the argument is examined to determine if it is valid for the control. If Key is not a valid character, it is set to #0 to ignore the key press event.

KeyPress disallows any value in Key that is not a numeric digit, sign character ('+' or '-'), scientific exponentiation symbol ('E' or 'e'), or decimal point character ('.' or ','). The decimal point is automatically converted to the value used in the DefaultFormatSettings variable from the RTL. The decimal point is not allowed when Decimals is set to 0 (zero).

KeyPress does not ensure that the value in Key is valid for a specific position in the control value. It does not guarantee that sign indicators are used only at the start of the control value. Nor does it guarantee that a decimal point character is not used more than once in the entered value. This is implemented in a manner that is Delphi compatible.

Tab (#9), BackSpace (#8), Cut (^X), Paste (^V), Copy (^C), and Undo (^Z) characters are allowed in Key so that they may be applied in inherited methods for the control.


Version 4.0 Generated 2025-05-03 Home