procedure TForm.ImageEnView1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // if (Button = mbLeft) and (SaveX = X) and (SaveY = Y) and (ImageEnView1.FindLayerAt(X, Y) = -1) then begin ImageEnView1.LayersDeselectAll; end; end;
Clicking on an area without any layers: On MouseUp the code successfully deselects all layers about 1/2 the time. The other 1/2 a shape is still under the mouse (FindLayerAt <> -1);
I want the users to be able to deselect all ShapeLayers by clicking on an unpopulated area of ImageEnView1.
The way it works now is clicking on an unpopulated area leads to the same or another ShapeLayer being selected.
My code works half the time because a new ShapeLayer appears automatically when an unpopulated area gets clicked. FindLayerAt(X, Y) can wrongly return populated because this ShapeLayer may be present for a while.
Actually, ImageEn should be deselecting the layer when clicking an unpopulated area anyway. I will fix that for v9.2.6 (late next week). You can email me for the source if you like.