ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Strange side-effects after (repeated) switching between eraser brush and normal
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

966 Posts

Posted - May 01 2025 :  08:43:09  Show Profile  Reply
I have a button that switches ImageEnView between eraser brush mode and select mode:

procedure TformInsertInternalImage.cxButtonEraserClick(Sender: TObject);
begin
  // strange side-effects after (repeated) switching between these two functionalities:

  if cxButtonEraser.Tag = 0 then
  begin
    cxButtonEraser.Tag := 1;
    cxButtonEraser.OptionsImage.ImageIndex := 1; // Eraser glyph colored
    ImageEnViewInsertInternal.BrushTool.BrushFill  := iebfEraser;
    ImageEnViewInsertInternal.BrushTool.BrushSize  := 32;
    ImageEnViewInsertInternal.MouseInteractGeneral := [miBrushTool]; // this CLEARS MouseInteractLayers!
  end
  else if cxButtonEraser.Tag = 1 then
  begin
    cxButtonEraser.Tag := 0;
    cxButtonEraser.OptionsImage.ImageIndex := 0; // Eraser glyph grey
    ImageEnViewInsertInternal.MouseInteractGeneral := [miSelect];

    // This is explicitly needed to RESTORE MouseInteractLayers - but after repeated switching, mlMoveLayers SOMETIMES is not restored(!):
    ImageEnViewInsertInternal.MouseInteractLayers := [mlMoveLayers,mlResizeLayers,mlRotateLayers];
  end;
end;


After repeated switching, mlMoveLayers SOMETIMES is not restored! This means that when I add a Layer after repeated switching, the Layer cannot be moved!

Is this a bug, or does my code need to be fixed?

xequte

38978 Posts

Posted - May 01 2025 :  16:20:39  Show Profile  Reply
Hi Peter

I tried to reproduce this but i could not. Is there anything else going on in the form at the same time?

procedure Tfmain.Button4Click(Sender: TObject);
var
  i: Integer;
begin
  // Try to reproduce strange side-effects after (repeated) switching between these two functionalities:
  for i := 1 to 5000 do
  begin
    if Button4.Tag = 0 then
    begin
      Button4.Tag := 1;
      // cxButtonEraser.OptionsImage.ImageIndex := 1; // Eraser glyph colored
      ImageEnView1.BrushTool.BrushFill  := iebfEraser;
      ImageEnView1.BrushTool.BrushSize  := 32;
      ImageEnView1.MouseInteractGeneral := [miBrushTool]; // this CLEARS MouseInteractLayers!
    end
    else
    // if Button4.Tag = 1 then
    begin
      Button4.Tag := 0;
      // cxButtonEraser.OptionsImage.ImageIndex := 0; // Eraser glyph grey
      ImageEnView1.MouseInteractGeneral := [miSelect];

      // This is explicitly needed to RESTORE MouseInteractLayers - but after repeated switching, mlMoveLayers SOMETIMES is not restored(!):
      ImageEnView1.MouseInteractLayers := [mlMoveLayers,mlResizeLayers,mlRotateLayers];

      if not ( mlMoveLayers in ImageEnView1.MouseInteractLayers) then
        raise Exception.create( 'Error' );
    end;

    Application.ProcessMessages();
  end;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PeterPanino

966 Posts

Posted - May 04 2025 :  01:18:22  Show Profile  Reply
Hi Nigel,

Layer properties like mlMoveLayers are generally controlled by ImageEnView1.MouseInteractLayers, which is usually set at design time. Is it advisable to (additionally) set MouseInteractLayers in OnLayerNotify?:

procedure TForm1.ImageEnView1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
var
  TextLayer: iexLayers.TIETextLayer;
begin
  // if a layer is selected (either by the user or programmatically):
  if event = ielSelected then
  begin
    // make Layers always movable, resizable, rotatable:
    ImageEnView1.MouseInteractLayers := [mlMoveLayers,mlResizeLayers,mlRotateLayers];
  end;
end;
Go to Top of Page

xequte

38978 Posts

Posted - May 05 2025 :  02:35:20  Show Profile  Reply
Hi Peter

Sorry, I'm not understanding your purpose here. Why do you need this code for the ielSelected event (rather than elsewhere)?

Personally I would avoid setting layer interactions in the LayerNotify event. There is a small chance that changing the interactions, might retrigger LayerNotify.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: