Sign in Join
FPDoc Onlineexperiment

TCustomGrid.KeyPress procedure

Member of TCustomGridprotectedIn unit Grids

Applies the specified key press character to the control.

Declaration

pascal
procedure KeyPress(var Key: char); override

Arguments

Key

Key press character examined in the method.

Description

KeyPress is a method used to apply the character in Key to the grid control. KeyPress is overridden to ensure that a key which originated from the grid control is applied properly to the cell Editor (when needed). It calls the inherited method on entry to signal the OnKeyPress event handler (when assigned).

KeyPress uses the value in EditorKey to determine if Key applies to an active cell Editor on the control. If KeyDown did not flag the value for the Editor control, the following values in Key are handled in the method:

Enter (#13)
Gets and displays the cell Editor when EditMode is False and the column allows editing. This includes signalling the OnSelectEditor event handler (when assigned).
Backspace (^H), and characters in the range #32..#255 (data)
Calls EditorShowChar to apply the key press to the Editor (when editing is enabled).

When Key is handled in the method, it is set to #0 prior to exit.

The SendCharToEditor implementation in the Windows widgetset was modified in LCL version 4.0. It changed the message delivery mechanism from PostMessageW (asynchronous) to SendMessageW (synchronous) to avoid duplicate or unintentional message delivery to the grid and/or cell editor controls.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.