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
 Layer click
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

egrobler

42 Posts

Posted - Sep 23 2012 :  11:23:16  Show Profile  Reply
Hi

How can I determine if a user clicked on a particular layer.

Thanks
Eric

w2m

USA
1990 Posts

Posted - Sep 23 2012 :  14:42:33  Show Profile  Reply
The OnLayerNotify event occurs whenever a layer is selected, moved or resized.
procedure TForm1.ImageEnView1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
var
  iDimensions: string;
begin
  if event = ielSelected then
  begin
    // user selected a layer 
    // layer is the layer index of the selected layer
    // to get layer info look at layer property
    // you can get the layers width, height, position... 
    iDimensions := IntToStr(ImageEnView1.Layers[layer].Width) + '     pixels x ' + IntToStr(ImageEnView1.Layers[layer].Height) + ' pixels';
  end;
end;

Look at the help file as well.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

egrobler

42 Posts

Posted - Sep 23 2012 :  23:40:37  Show Profile  Reply
Hi William,

Thanks for your response.

My problem is that OnLayerNotify is not fired with my settings which is MouseInteract := [miSelect]. I do not want to use miMoveLayers.

I have a background with various icons and would like to react if the user clicks on any of the layers (icons)

Regards
Eric
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 24 2012 :  07:03:35  Show Profile  Reply
Try this:
procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  iLayer: integer;
begin
  iLayer:= ImageEnView1.FindLayerAt(X, Y, True);
  StatusBar1.Panels[6].Text := 'Current layer: ' + IntToStr(iLayer) + '.'
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

egrobler

42 Posts

Posted - Sep 24 2012 :  07:28:11  Show Profile  Reply
Thanks William

iLayer:= ImageEnView1.FindLayerAt(X, Y, True);

It works perfectly :-)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: