Sign in Join
FPDoc Onlineexperiment

TCustomColorBox.OnGetColors property

Member of TCustomColorBoxpublicIn unit ColorBox

OnGetColors - event handler for the instruction to get colors.

Declaration

pascal
property OnGetColors: TGetColorsEvent read FOnGetColors write FOnGetColors;

Description

OnGetColors is a TGetColorsEvent property with the event handler signalled to get custom colors used in the combo-box control.

An application must implement and assign an object procedure using the signature in TGetColorsEvent to respond to the notification. Sender is the TCustomColorBox control for the event notification. Items is the TStrings instance with the existing color names and values stored in the control.

The event handler can perform any actions needed to populate the list of Items. This can include clearing the Items, adding or removing selected names and color values, or using color names and/or values not defined as color constants in the graphics.pp unit. It could also be used to implement a custom color palette with specific pre-defined color combinations.

Some common operations:

Clear the list of ltems:

Items.Clear;

Add a specific color:

Items.AddObject(rsSkyBlueColorCaption, 
TObject(PtrInt(clSkyBlue)));

Delete a specific color:

iPos := Items.IndexOf(rsSkyBlueColorCaption);
if iPos <> -1 then
Items.Delete(iPos);

OnGetColors is signalled (when assigned) when the color list is loaded for the control, and cbCustomColors has been included in the Style for the control. This occurs when a new value is assigned to the Style property.

See also

An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.