Let me see if I'm understanding correctly. Conceptually, you have, let's say, "groups" of overlaping shapes (along with independent ones) and inside each group you want to know when the user is entering, say, Shape1, Shape 2, or the intersection of both.
Shape "grouping" is relatively easy to achieve; you could, for example, use their Tag property to store a "group number" and test in the handler:
procedure TForm1.EnterShape(Sender: TObject);
const
Current: TShape = nil;
GroupId: Integer = 0;
var
i: Integer;
function InGroup(AComponent: TComponent): Boolean;
begin
Result := AComponent.InheritsFrom(TShape)
and (AComponent <> Current)
and (AComponent.Tag = GroupId);
end;
begin
if Sender.InheritsFrom(TShape) then begin
Memo1.Lines.Add('Shape: %s', [TComponent(Sender).Name]);
if not Assigned(Current) then begin
Current := TShape(Sender);
GroupId := Current.Tag;
if GroupId <> 0 then
for i := 0 to ComponentCount-1 do
if InGroup(Component[i]) then
EnterShape(Components[i]);
Current := Nil;
GroupId := 0;
Memo1.Lines.Add('----------');
end;
end;
end;
Now it will process only those shapes inside the same "group", based on the Tag of the first one.
As for ascertaining whether the user is in one shape, or other, or the intersection ... that's a little more complex; for example, you might set a handler for
OnMouseDown(). That gives you the coordinates of the mouse at clicking time, which you can test (through a process similar to the above) against the surrounding shapes's boundaries. It's a little late now but I'll try to write an example tomorrow, if I get some free time