fixed unselecting TCollection

git-svn-id: trunk@6905 -
This commit is contained in:
mattias 2005-03-05 22:31:35 +00:00
parent c55ae368e5
commit 98d9003cad
3 changed files with 62 additions and 5 deletions

View File

@ -351,10 +351,24 @@ begin
end;
procedure TDesigner.DeleteFormAndFree;
var
i: Integer;
begin
Include(FFlags,dfDestroyingForm);
if FLookupRoot is TComponent then
if FLookupRoot is TComponent then begin
// unselect
for i:=FLookupRoot.ComponentCount-1 downto 0 do
TheControlSelection.Remove(LookupRoot.Components[i]);
TheControlSelection.Remove(LookupRoot);
if GlobalDesignHook.LookupRoot=FLookupRoot then
GlobalDesignHook.LookupRoot:=nil;
// tell hooks about deleting
for i:=FLookupRoot.ComponentCount-1 downto 0 do
GlobalDesignHook.PersistentDeleting(FLookupRoot.Components[i]);
GlobalDesignHook.PersistentDeleting(FLookupRoot);
// delete
TheFormEditor.DeleteComponent(FLookupRoot,true);
end;
Free;
end;
@ -1643,7 +1657,7 @@ begin
ControlSelection.Remove(APersistent);
if (APersistent is TComponent)
and (TheFormEditor.FindComponent(TComponent(APersistent))=nil) then begin
// thsi component is currently in the process of deletion or the component
// this component is currently in the process of deletion or the component
// was not properly created
// -> do not call handlers and simply get rid of the rubbish
//writeln('TDesigner.DoDeleteComponent UNKNOWN ',AComponent.Name,':',AComponent.ClassName,' ',HexStr(Cardinal(AComponent),8));

View File

@ -4240,7 +4240,7 @@ begin
if (AForm=nil) then exit;
if FLastFormActivated=AForm then
FLastFormActivated:=nil;
// unselect controls
// unselect components
for i:=LookupRoot.ComponentCount-1 downto 0 do
TheControlSelection.Remove(LookupRoot.Components[i]);
TheControlSelection.Remove(LookupRoot);
@ -11457,6 +11457,9 @@ end.
{ =============================================================================
$Log$
Revision 1.853 2005/03/05 22:31:34 mattias
fixed unselecting TCollection
Revision 1.852 2005/03/02 15:59:53 mattias
accelerated identifier completion

View File

@ -1036,6 +1036,9 @@ procedure UpdateListPropertyEditors(AnObject: TObject);
editors, the object inspector and the form editor.
}
type
{ TPersistentSelectionList }
TPersistentSelectionList = class
protected
FUpdateLock: integer;
@ -1057,6 +1060,7 @@ type
property Count:integer read GetCount;
property Capacity:integer read GetCapacity write SetCapacity;
function Add(APersistent: TPersistent): integer;
function Remove(APersistent: TPersistent): integer;
procedure Assign(SourceSelectionList: TPersistentSelectionList);
property Items[AIndex: integer]: TPersistent read GetItems write SetItems; default;
end;
@ -1169,6 +1173,8 @@ type
htRefreshPropertyValues
);
{ TPropertyEditorHook }
TPropertyEditorHook = class
private
FHandlers: array[TPropHookType] of TMethodList;
@ -1213,6 +1219,7 @@ type
procedure DeletePersistent(var APersistent: TPersistent);
procedure GetSelection(const ASelection: TPersistentSelectionList);
procedure SetSelection(const ASelection: TPersistentSelectionList);
procedure Unselect(const APersistent: TPersistent);
procedure SelectOnlyThis(const APersistent: TPersistent);
// persistent objects
function GetObject(const Name: ShortString):TPersistent;
@ -3602,10 +3609,16 @@ end;
procedure TCollectionPropertyEditorForm.PersistentDeleting(
APersistent: TPersistent);
var
OldCollection: TCollection;
begin
//debugln('TCollectionPropertyEditorForm.PersistentDeleting A APersistent=',dbgsName(APersistent),' OwnerPersistent=',dbgsName(OwnerPersistent));
if APersistent=OwnerPersistent then begin
OldCollection:=Collection;
SetCollection(nil,nil,'');
GlobalDesignHook.Unselect(OldCollection);
if GlobalDesignHook.LookupRoot=OldCollection then
GlobalDesignHook.LookupRoot:=nil;
Hide;
end;
end;
@ -3635,8 +3648,12 @@ begin
CollectionListBox.Items[I]:=CurItem;
end;
// delete unneeded list items
while CollectionListBox.Items.Count>Cnt do begin
CollectionListBox.Items.Delete(CollectionListBox.Items.Count-1);
if Cnt>0 then begin
while CollectionListBox.Items.Count>Cnt do begin
CollectionListBox.Items.Delete(CollectionListBox.Items.Count-1);
end;
end else begin
CollectionListBox.Items.Clear;
end;
CollectionListBox.Items.EndUpdate;
@ -3730,6 +3747,7 @@ var
i: Integer;
NewSelection: TPersistentSelectionList;
begin
if Collection=nil then exit;
// select in OI
NewSelection:=TPersistentSelectionList.Create;
try
@ -5206,6 +5224,12 @@ begin
Result:=FPersistentList.Add(APersistent);
end;
function TPersistentSelectionList.Remove(APersistent: TPersistent): integer;
begin
Result:=IndexOf(APersistent);
if Result>=0 then FPersistentList.Remove(APersistent);
end;
procedure TPersistentSelectionList.Clear;
begin
FPersistentList.Clear;
@ -5610,6 +5634,22 @@ begin
//writeln('TPropertyEditorHook.SetSelection END ASelection.Count=',ASelection.Count);
end;
procedure TPropertyEditorHook.Unselect(const APersistent: TPersistent);
var
Selection: TPersistentSelectionList;
begin
Selection:=TPersistentSelectionList.Create;
try
GetSelection(Selection);
if Selection.IndexOf(APersistent)>=0 then begin
Selection.Remove(APersistent);
SetSelection(Selection);
end;
finally
Selection.Free;
end;
end;
procedure TPropertyEditorHook.SelectOnlyThis(const APersistent: TPersistent);
var
NewSelection: TPersistentSelectionList;