Class TLCLKeyPressHandler

Unit

Declaration

type TLCLKeyPressHandler = class(TObject)

Description

Convert LCL OnKeyDown and OnUTF8KeyPress into a single CGE event OnPress.

In VCL and LCL KeyPress (or UTF8KeyPress in LCL) and KeyDown are separate events. While in CGE they are one event, and passed as one event to TCastleUserInterface.KeyDown, because this is more comfortable to process (as it corresponds to one user action, and allows configurable TInputShortcut to work).

Hierarchy

Overview

Methods

Public procedure KeyDown(const Key: Word; const Shift: TShiftState);
Public procedure UTF8KeyPress(const UTF8Key: TUTF8Char);
Public procedure BeforeKeyUp(const Key: Word; const Shift: TShiftState);
Public procedure Flush;

Properties

Public property OnPress: TControlInputPressReleaseEvent read FOnPress write FOnPress;

Description

Methods

Public procedure KeyDown(const Key: Word; const Shift: TShiftState);

Call these events when corresponding Lazarus event (OnKeyDown, OnUTF8KeyPress) occurs.

They may call OnPress in turn.

Public procedure UTF8KeyPress(const UTF8Key: TUTF8Char);
 
Public procedure BeforeKeyUp(const Key: Word; const Shift: TShiftState);

Call this when Lazarus OnKeyUp event occurs.

It may call OnPress in return. Receiving "key up" event from Lazarus may indicate that we have to do OnPress now.

This matters for keys without corresponding String/Char representation (thus, without UTF8KeyPress call), like keyArrowLeft. If we have buffered to "send the OnPress for this key", we need to send it now, before the OnRelease for the same key is generated. Otherwise the KeyUp would cause OnRelease of the arrow key, and later Flush call would send OnPress for the same key.

Public procedure Flush;

If some keypress is half-finished, report it now. This should be called before e.g. Update event, to report events that result in OnKeyDown but not OnUTF8KeyPress, or OnUTF8KeyPress but not OnKeyDown.

Properties

Public property OnPress: TControlInputPressReleaseEvent read FOnPress write FOnPress;

Called when we collect enough information to make a CGE press event.


Generated by PasDoc 0.16.0.