IdeIntf: Show '(Invalid)' in OI when an invalid enum value was typed.

git-svn-id: trunk@55832 -
This commit is contained in:
juha 2017-09-10 18:10:17 +00:00
parent 3c4942286a
commit 2e97bb8617

View File

@ -464,9 +464,12 @@ type
(sCircle, sTriangle, sSquare), etc.). }
TEnumPropertyEditor = class(TOrdinalPropertyEditor)
private
FInvalid: Boolean;
public
function GetAttributes: TPropertyAttributes; override;
function OrdValueToVisualValue(OrdValue: longint): string; override;
function GetVisualValue: ansistring; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure SetValue(const NewValue: ansistring); override;
end;
@ -3637,6 +3640,14 @@ begin
Result := GetEnumName(GetPropType, L);
end;
function TEnumPropertyEditor.GetVisualValue: ansistring;
begin
if FInvalid then
Result := '(Invalid)'
else
Result := inherited GetVisualValue;
end;
procedure TEnumPropertyEditor.GetValues(Proc: TGetStrProc);
var
I: Integer;
@ -3656,11 +3667,9 @@ var
I: Integer;
begin
I := GetEnumValue(GetPropType, NewValue);
if I < 0 then begin
{raise EPropertyError.CreateRes(@SInvalidPropertyValue)};
exit;
end;
SetOrdValue(I);
FInvalid := I < 0;
if not FInvalid then
SetOrdValue(I);
end;
{ TBoolPropertyEditor }