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
 How to invoke the context menu of a right-clicked Layer?

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 02 2023 : 14:49:25
I need to show the Layer Properties dialog for a selected Layer, either by:

1. Invoking the Layer's context menu by right-clicking the Layer and selecting the Layer Properties Dialog menu item, or:
2. Programmatically invoking the Layer's Property dialog, e.g., by double-clicking the Layer while holding the CTRL key.


Unfortunately, when I right-click a Layer, no Layer context menu is shown, but rather a context menu with items that refer to the whole image (not to the Layer) is shown:



I suppose it is a fundamental and obvious UI feature to show the context menu of the right-clicked object and not the context menu of a completely different object. So how can I show the context menu of the right-clicked Layer?
11   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 05 2023 : 17:07:29
Hi Peter

We're hoping to get it out before the end of May, but you can email me for a beta.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - May 05 2023 : 03:39:58
Hi Nigel,

I have read the documentation:

http://www.imageen.com/help/TIEGlobalSettings.OnAddPopupMenuItem.html

So I'm looking forward to the improvements in v12.0.5. When will it be available?

Thank you again for the fantastic ImagEn and your support!
xequte Posted - May 04 2023 : 22:06:53
Hi Peter

Please read the documentation:

http://www.imageen.com/help/TIEGlobalSettings.OnAddPopupMenuItem.html

The event occurs once for each item specified by the popup menu property, so you need to add it to the popup list to be offered.

However this is one of the things that is changed in the upcoming 12.0.5. From v12.0.5 all items are output to OnAddPopupMenuItem, OnAddToolbarButton, etc, and you can include/exclude more simply.

You can email me for a beta if you like.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - May 04 2023 : 17:00:41
Meanwhile, I use this code to configure the LayerSelection context menu:

procedure TformMain.FormCreate(Sender: TObject);
begin
  // layer-Popupmenu:
  IEGlobalSettings().LayerSelectionPopupMenu := [
    ivbLayersPropsDlg,   // TImageEnViewLayersShowPropertiesDialog
    ivbLayersGroup,      // TImageEnViewLayersGroup, TImageEnViewLayersUngroup
    ivbLayersOther,      // IELayerFlipHorz_Button_ID, IELayerFlipVert_Button_ID
    ivbLayersStyle,      // TIELayerFill, TIELayerBorder, TIELayerBorderWidth
    ivbLayersSize,       // TIELayerRestoreAspectRatio, TIELayerSizeToFit, TIEImageLayerRestoreSize
    //ivbLayersProps,
    //ivbLayersEdit,
    ivbLayersEditCurrent // TImageEnViewLayersMergeToBackground, TImageEnViewLayersRemoveCurrent,
                         // TImageEnViewLayersCropBackground, TIELayerConvertToImageLayer
  ];


This results in the following Layer context menu:



However, to achieve better fine-tuning, it would be important that the "TIEGlobalSettings.OnAddPopupMenuItem" would work as intended.
PeterPanino Posted - May 04 2023 : 13:43:31
Hi Nigel,

I want to add an item to the popup context menu when right-clicking a Layer: Merge to Background.

So I followed your link above and applied the example on the page "TIEGlobalSettings.OnAddPopupMenuItem":

procedure TformMain.IEGlobalSettings1AddPopupMenuItem(Sender: TObject; ToolbarID, ButtonID: Integer; var Include: Boolean);
begin
  if ToolbarID = Layer_Selection_PopupMenu_ID  then
  begin
    if ButtonID = IELayersMergeToBackground_Button_ID then
      Include := True;
  end;
end;


Unfortunately, it does not work. So how can I add the desired menu item?

In other words: What is the TIEGlobalSettings.OnAddPopupMenuItem event handler good for if it does not work?
PeterPanino Posted - May 03 2023 : 05:40:25
This adds more flexibility by showing the CONTEXT TOOLBAR instead of the context menu when holding down the CTRL key while right-clicking a Layer:

procedure TformMain.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  var ThisLayer := ImageEnView1.FindLayerAt(X, Y);

  if Button = mbLeft then
  begin
    ImageEnView1.AutoToolbars := [];
    // ...
  end
  else if Button = mbRight then
  begin	
    if ThisLayer > 0 then // right-clicked a floating Layer (not the Background)
    begin
      // only CTRL modifier key pressed:
      if (GetKeyState(VK_CONTROL) < 0) and (GetKeyState(VK_SHIFT) >= 0) and (GetKeyState(VK_MENU) >= 0) then
      begin
        ImageEnView1.PopupMenus := [];
        ImageEnView1.AutoToolbars := [ievLayerEditing, ievLayerSelection];
      end
      // NO modifier key pressed:
      else if (GetKeyState(VK_CONTROL) >= 0) and (GetKeyState(VK_SHIFT) >= 0) and (GetKeyState(VK_MENU) >= 0) then
      begin
        ImageEnView1.PopupMenus := [ievLayerEditing, ievLayerSelection];
        ImageEnView1.AutoToolbars := [];
      end
    end
    else if ThisLayer = 0 then // right-clicked the Background Image
    begin
      ImageEnView1.PopupMenus := [ievViewing, ievEditing, ievSelection];
      ImageEnView1.AutoToolbars := [];
    end;
  end;	
end;


I love the flexibility in ImageEn.

Layer context menu with no modifier keys pressed:



Layer context toolbar with CTRL key pressed:

PeterPanino Posted - May 03 2023 : 03:22:11
I have now found the most simple/best solution that works perfectly:

procedure TformMain.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  var ThisLayer := ImageEnView1.FindLayerAt(X, Y);

  if Button = mbLeft then
  begin
    // ...
  end
  else if Button = mbRight then
  begin
    if ThisLayer > 0 then
      ImageEnView1.PopupMenus := [ievLayerEditing, ievLayerSelection]
    else if ThisLayer = 0 then 
      ImageEnView1.PopupMenus := [ievViewing, ievEditing, ievSelection];
  end;
end;


Now the correct context menu is shown in any case!
PeterPanino Posted - May 03 2023 : 02:18:57
"If you need more configuration"

IMO, showing the correct context menu for the right-clicked object should be automatically controlled by ImageEn: Nobody would want to show the Layer context menu when right-clicking Layer 0 (the background image).
xequte Posted - May 02 2023 : 20:30:45
Hi Peter

The background image is also a layer (Layer 0). If you need more configuration, use the event:

https://www.imageen.com/help/TIEGlobalSettings.OnAddPopupMenuItem.html

Or build your own context menu (e.g. using the ImageEn action classes).



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - May 02 2023 : 17:33:53
Hi Nigel,

I've tried that already. But this shows the Layer context menu even when I right-click a regular image without any Layer present:

xequte Posted - May 02 2023 : 16:24:45
Hi Peter

What is the value for ImageEnView1.PopupMenus?

http://www.imageen.com/help/TImageEnView.PopupMenus.html

It should be:

// Display popup with buttons relevant to editing layers. If right-clicking a layer, it changes to methods for the current layer
ImageEnView1.PopupMenus := [ ievLayerEditing, ievLayerSelection ];


Nigel
Xequte Software
www.imageen.com