IDEIntf: TOIPropertyGrid: distinguish calling property Edit and changing the value

git-svn-id: trunk@44226 -
This commit is contained in:
mattias 2014-02-24 10:59:57 +00:00
parent fdc2fe0d53
commit 56d751c730

View File

@ -220,7 +220,8 @@ type
pgsUpdatingEditControl,
pgsBuildPropertyListNeeded,
pgsGetComboItemsCalled,
pgsIdleEnabled
pgsIdleEnabled,
pgsCallingEdit // calling property editor Edit
);
TOIPropertyGridStates = set of TOIPropertyGridState;
@ -789,7 +790,10 @@ type
const
DefaultObjectInspectorName: string = 'ObjectInspectorDlg';
// the ObjectInspector of the IDE can be found in FormEditingIntf
// the ObjectInspector descendant of the IDE can be found in FormEditingIntf
function dbgs(s: TOIPropertyGridState): string; overload;
function dbgs(States: TOIPropertyGridStates): string; overload;
implementation
@ -825,6 +829,25 @@ begin
TOIPropertyGridRow(Item2).Name);
end;
function dbgs(s: TOIPropertyGridState): string;
begin
Result:=GetEnumName(TypeInfo(s),ord(s));
end;
function dbgs(States: TOIPropertyGridStates): string;
var
s: TOIPropertyGridState;
begin
Result:='';
for s in States do
begin
if not (s in States) then continue;
if Result<>'' then Result+=',';
Result+=dbgs(s);
end;
Result:='['+Result+']';
end;
{ TOICustomPropertyGrid }
constructor TOICustomPropertyGrid.CreateWithParams(AnOwner:TComponent;
@ -1402,10 +1425,10 @@ begin
end;
// set value in edit control
SetCurrentEditValue(CurRow.Editor.GetVisualValue);
SetCurrentEditValue(Editor.GetVisualValue);
// update volatile sub properties
if (paVolatileSubProperties in CurRow.Editor.GetAttributes)
if (paVolatileSubProperties in Editor.GetAttributes)
and ((CurRow.Expanded) or (CurRow.ChildCount>0)) then begin
OldExpanded:=CurRow.Expanded;
ShrinkRow(FItemIndex);
@ -1440,14 +1463,14 @@ begin
{$ENDIF}
DebugLn(['#################### TOICustomPropertyGrid.DoCallEdit for ',
CurRow.Editor.ClassName,' Edit=',Edit=oiqeEdit]);
Include(FStates,pgsApplyingValue);
Include(FStates,pgsCallingEdit);
try
if Edit=oiqeShowValue then
CurRow.Editor.ShowValue
else
CurRow.Editor.Edit;
finally
Exclude(FStates,pgsApplyingValue);
Exclude(FStates,pgsCallingEdit);
end;
{$IFNDEF DoNotCatchOIExceptions}
except
@ -1605,9 +1628,10 @@ var
NewValue: string;
EditorAttributes: TPropertyAttributes;
begin
//if FRows.Count=0 then
// debugln(['TOICustomPropertyGrid.SetItemIndex ',DbgSName(Self),' ',dbgsname(FCurrentEdit),' ',dbgs(FStates),' GridIsUpdating=',GridIsUpdating,' FItemIndex=',FItemIndex,' NewIndex=',NewIndex]);
if GridIsUpdating or (FItemIndex = NewIndex) then
exit;
// save old edit value
SetRowValue(true);
@ -2030,6 +2054,7 @@ var
begin
Result:=
not GridIsUpdating and IsCurrentEditorAvailable
and (not (pgsCallingEdit in FStates))
and ((FCurrentEditorLookupRoot = nil)
or (FPropertyEditorHook = nil)
or (FPropertyEditorHook.LookupRoot = FCurrentEditorLookupRoot));