ImageEn, unit imageenview




property MouseInteractLayers: TIEMouseInteractLayers;


An extension to MouseInteractGeneral for mouse activities related to layer editing and creation.

- Mouse interaction options are split into two properties: MouseInteractLayers and MouseInteractGeneral. Items of MouseInteractLayers relate only to layer editing and creation, whereas MouseInteractGeneral are all remaining options (selection, view, measurement and image editing functions)
- Multiple interactions can be specified, but activities that are not mutually compatible will be excluded
- Setting MouseInteractLayers, will also remove incompatible items from MouseInteractGeneral
- Use LayersResizeAspectRatio to control aspect ratio locking behaviour
- Layer interactions can not be set when the PDFViewer is enabled


Demo  Demos\Other\MouseInteract\MouseInteract.dpr
Demo  Demos\LayerEditing\RotateLayers\RotateLayers.dpr
Demo  Demos\LayerEditing\Layers_AllTypes\Layers.dpr
Demo  Demos\LayerEditing\Layers_Lines\Layers.dpr

Compatibility Notes

Prior to v8.6.0, all mouse interactions (both MouseInteractGeneral and MouseInteractLayers items) were set with a single property MouseInteract. To overcome the size limitation for published sets, this was split into:

- MouseInteractGeneral: All mouse interactions that are not related to layer editing
- MouseInteractLayers: Mouse interactions for layer editing

In most cases, code that was previously:
ImageEnView1.MouseInteract := [ miZoom, miScroll ];

Simply changes to:
ImageEnView1.MouseInteractGeneral := [ miZoom, miScroll ];

However for layer editing items (miMoveLayers, miResizeLayers, miRotateLayers, miCreate*Layers, etc.), the prefix has changed to ml, and you must reference MouseInteractLayers.

In older versions:
ImageEnView1.MouseInteract := [ miMoveLayers, miResizeLayers ];

Now becomes:
ImageEnView1.MouseInteractLayers := [ mlMoveLayers, mlResizeLayers ];

These are the layer editing items: miMoveLayers, miResizeLayers, miRotateLayers, miCreateImageLayers, miCreateShapeLayers, miCreateLineLayers, miCreatePolylineLayers, miCreateTextLayers, miClickCreateLineLayers, miClickCreatePolylineLayers, miDrawCreatePolylineLayers, miEditLayerPoints
They are now named: mlMoveLayers, mlResizeLayers, mlRotateLayers, mlCreateImageLayers, mlCreateShapeLayers, mlCreateLineLayers, mlCreatePolylineLayers, mlCreateTextLayers, mlClickCreateLineLayers, mlClickCreatePolylineLayers, mlDrawCreatePolylineLayers, mlEditLayerPoints


// Allow users to create image layers. Prompt for an image file after selection
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAutoPromptForImage ];
ImageEnView1.MouseInteractLayers := [ mlCreateImageLayers ];

// Allow user to move and resize layers (allow multiple layer selection and ensure masks are moved with layers)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAllowMultiSelect, loAutoSelectMask ];
ImageEnView1.MouseInteractLayers := [ mlMoveLayers, mlResizeLayers ];

A selected text layer with resize grips:

Four selected layers with resize grips:

// Allow user to rotate layers (allow multiple layer selection and ensure masks are moved with layers)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAllowMultiSelect, loAutoSelectMask ];
ImageEnView1.MouseInteractLayers := [ mlRotateLayers ];

// Allow the user to create, size and rotate red arrows
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loShowRotationGrip ];
ImageEnView1.MouseInteractLayers := [ mlCreateLineLayers, mlMoveLayers, mlResizeLayers, mlRotateLayers ];
ImageEnView1.LayerDefaults.Values[ IELP_LineColor ] := 'clRed';
ImageEnView1.LayerDefaults.Values[ IELP_LineWidth ] := '6';
ImageEnView1.LayerDefaults.Values[ IELP_LineShapeSize ] := '20';
ImageEnView1.LayerDefaults.Values[ IELP_LineStartShape ] := '1';
ImageEnView1.LayerDefaults.Values[ IELP_Rotate ] := '235';

// Allow user to create star shapes at preferred aspect ratio
ImageEnView1.LayersResizeAspectRatio := iearAlways;
IEGlobalSettings().DefaultLayerShape := iesStar5;
ImageEnView1.MouseInteractLayers := [ mlCreateShapeLayers ];

// Allow user to draw a polygon
ImageEnView1.LayersAutoClosePolylines := iecmAlways;
ImageEnView1.MouseInteractLayers := [ mlClickCreatePolylineLayers ];

// Allow users to create and edit a polyline
ImageEnView1.LayersAutoClosePolylines := iecmManual;
ImageEnView1.MouseInteractLayers := [ mlClickCreatePolylineLayers, mlEditLayerPoints ];

// Allow users to edit a polyline. Hold Alt key to turn line into a curve
ImageEnView1.MouseInteractLayers := [ mlEditLayerPoints ];

// Allow users to draw rulers (lines with measurement values)
With ImageEnView1.LayerDefaults do
  Values[ IELP_IsRuler ] := 'True';
  Values[ IELP_RulerUnits ] := IntToStr( ord( ieuCentimeters ));
  Values[ IELP_LabelPosition ] := IntToStr( ord( ielpAutoAbove ));
  Values[ IELP_LineStartShape ] := IntToStr( ord( ieesBar ));
  Values[ IELP_LineEndShape ] := IntToStr( ord( ieesBar ));
  Values[ IELP_LineWidth ] := '2';
IEGlobalSettings().MeasureDecimalPlaces := 1;
ImageEnView1.MouseInteractLayers := [ mlClickCreateLineLayers, mlEditLayerPoints ];

// Allow users to create text layers. Start in text editing mode (user can immediately begin typing text)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAutoTextEditing ];
ImageEnView1.MouseInteractLayers := [ mlCreateTextLayers ];

// Add a star every time the layer clicks on the image (use OnNewLayer event to customize size)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loStampMode ];
IEGlobalSettings().DefaultLayerShape := iesStar5;
ImageEnView1.MouseInteractLayers := mlCreateShapeLayers;

// Allow user to make selections when there are multiple layers (current layer will be highlighted. Selecting a new layer will highlight and allow selection. Layer movement is not actually possible)
ImageEnView1.MouseInteractGeneral := [ miSelect, mlMoveLayers ];

// Allow user to make selections when there are multiple layers, including resizing and rotating layers
ImageEnView1.MouseInteractGeneral := [ miSelect, mlMoveLayers, mlResizeLayers, mlRotateLayers ];

See Also

- SelectionOptions
- LayerDefaults
- LayersAutoClosePolylines
- OnUserInteraction
- OnLayerNotifyEx
- TIEUserInteraction
- MouseInteractGeneral