ImageEn, unit imageenview




property MouseInteractGeneral: TIEMouseInteract;


Specify which mouse activities are performed when the user interacts with the ImageEnView component with the mouse.

- Mouse interaction options are split into two properties: MouseInteractGeneral and MouseInteractLayers. 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 MouseInteractGeneral, will also remove incompatible items from MouseInteractLayers



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


// Single left click zoom-in image, single right click zoom-out image, click and
// drag scroll the image (if it is bigger than client area).
ImageEnView1.MouseInteractGeneral := [ miZoom, miScroll ];

// Allow circular selections
ImageEnView1.MouseInteractGeneral := [ miSelectCircle ];

// Allow the user to select the background in an image with a chroma-key background
ImageEnView1.ChromaKeyOptions.Mode := iecSubject;
ImageEnView1.MouseInteractGeneral := [ miSelectChromaKey ];

// Allow zooming by selecting the image
ImageEnView1.MouseInteractGeneral := [ miSelectZoom ];
ImageEnView1.DisplayOptions := ImageEnView1.DisplayOptions + [iedoDisableAutoFitWhenZoom];

// Enable measuring of lengths in image (Imperial)
// Set scale of 250 pixels = one inch
ImageEnView1.SetScale( 250, 1, ieuInches );
IEGlobalSettings().DefaultMeasureUnit := ieuInches;
ImageEnView1.MouseInteractGeneral := [ miMeasureLength ];

// Enable measuring of lengths in image (Metric)
// Set 100 pixels = 4cm
ImageEnView1.SetScale( 100, 4, ieuCentimeters );
IEGlobalSettings().DefaultMeasureUnit := ieuCentimeters;
ImageEnView1.MouseInteractGeneral := [ miMeasureLength ];

// Select whole image and allow user to deselect circular regions
With ImageEnView1 do
  SelectionBase := iesbBitmap;
  Select( 0, 0, IEBitmap.Width, IEBitmap.Height );
  ShiftKeyLock := [ iessCtrl_SubFromSel ];
  MouseInteractGeneral := [ miSelectCircle ];

// Fill clicked areas with red
ImageEnView1.FillTool.ColorFillValue := clRed;
ImageEnView1.MouseInteractGeneral := [miColorFill];

// Fill clicked areas with 50% transparency
ImageEnView1.FillTool.AlphaFillValue := 128;
ImageEnView1.MouseInteractGeneral := [miAlphaFill];

// Selecting a color updates all tools
ImageEnView1.FillTool.ColorSelectActions := [ieccChromaKeyColor, ieccBrushColor, ieccFillColor, ieccRotateBackground, ieccLayerFill ];
ImageEnView1.MouseInteractGeneral := [ miColorPicker ];

// Use miColorPicker to set transparent parts of image

procedure TMainForm.btnSelColorClick(Sender: TObject);
  ImageEnView1.MouseInteractGeneral := [ miColorPicker ];

procedure TMainForm.ImageEnView1UserInteraction(Sender: TObject; Event: TIEUserInteractionEvent; Info: Integer);
  c: TColor;
  if Event = ieiColorPickerHover then
    // Hovering over image - show color in our panel
    pnlCurrentColor.Color := TColor( Info );
  if Event = ieiColorPickerClick then
    // Clicked image - set this color as transparent in our image
    c := TColor( Info );
    ImageEnView1.Proc.SetTransparentColors( c, c, 0);

See Also

- MouseInteractLayers
- SelectionOptions
- OnUserInteraction
- TIEUserInteraction