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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 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

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - May 01 2025 : 08:43:09
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?
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 05 2025 : 02:35:20
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
PeterPanino Posted - May 04 2025 : 01:18:22
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;
xequte Posted - May 01 2025 : 16:20:39
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