|
Input validation
TComponentInspector allows to validate the user input by OnValidateChar event. Set the event Result to True if the Key is valid char, otherwise to False. The following example shows how we can allow to enter only digits if the selected property is integer.
function TMainForm.ComponentInspectorValidateChar(Sender: TObject;
TheIndex: Integer; var Key: Char): Boolean;
begin
Result:=True;
if Assigned(ComponentInspector.Properties[TheIndex]) then
with ComponentInspector.Properties[TheIndex] do
if TypeKind=tkInteger then
Result:=
(PropType=TypeInfo(TColor)) or
(PropType=TypeInfo(TCursor)) or
(Key in ['0'..'9']);
end;
|