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
 Selecting Objects at a Location
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Elemental

USA
56 Posts

Posted - Mar 21 2014 :  15:30:46  Show Profile  Reply
I have a TImageEnVect component and I am wanting to allow the user to right-click the component and do things to the vector object they clicked, such as delete it or change the background color, and stuff like that.

I have a TPopupMenu attached to the imaging component for this purpose. But the problem is that right-clicking does not select the objects beneath the click. The user might have another object selected elsewhere, and when they right-click and Delete, it will delete the other selected object, which is what they don't want.

What property can I change so that right-clicking (with a pop-up attached) selects the objects under the mouse click *OR* what code can I use to select those objects under the mouse click, if I know the X, Y?

w2m

USA
1990 Posts

Posted - Mar 21 2014 :  15:48:11  Show Profile  Reply
I just tested this for you with the vectorial demo:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnVect1.SelectOnMouseDown := True;
end;

procedure TForm1.Delete1Click(Sender: TObject);
{ Delete the selected object from a popupmenu }
begin
   while ImageEnVect1.SelObjectsCount > 0 do
    ImageEnVect1.RemoveObject(ImageEnVect1.SelObjects[0]);
end;


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

Elemental

USA
56 Posts

Posted - Mar 21 2014 :  15:55:53  Show Profile  Reply
Yes, I tried setting that property at design- and run-time, but it still doesn't select the elements. If I disassociate the PopupMenu property, right-clicking still doesn't select the elements. I have also tried including iesoRightButtonSelectLayers in SelectionOptions and that doesn't work either. Currently, MouseInteractVt is set to [miObjectSelect]. What could I be missing?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 21 2014 :  15:57:52  Show Profile  Reply
I have no idea... in order to help you have to show all the appropriate code. Try adding a popupmenu to the vectorial demo then add my code. It works for me so it should work for you.

I might add when I tested this the object I wanted to delete was selected with left click BEFORE I popup the menu to delete the object.

William Miller
Go to Top of Page

Elemental

USA
56 Posts

Posted - Mar 24 2014 :  07:18:59  Show Profile  Reply
Yes, I've gotten it to work by left-clicking the object first and then right-clicking to raise the pop-up menu before deleting the object. But in my experience, this method is outdated. If I right-click something, I want that thing selected also so I can see my options. It's counter-intuitive that by right-clicking an annotation object and selecting Delete, that I'll actually be deleting some other selected object far away on the image. I want to provide my users with the ability to right-click an object, which also selects it, so then they can see their options, like "Delete".

Try the following methods now:

1) In your browser, have multiple tabs open. Select one so it's active. Right-click a different tab and opt to close it. Did you notice how the option you chose applies to the tab you right-clicked, and not to the tab that was active?

2) Single-click an icon on your desktop to select it. Now right-click another icon. See how the right-click selects it before opening a pop-up menu? This is what users expect, and this is what I want to duplicate in my ImageEn program with annotations.
Go to Top of Page

Elemental

USA
56 Posts

Posted - Mar 24 2014 :  07:42:36  Show Profile  Reply
OK. I just fixed it and it's awesome. I attached the TPopupMenu to the TImageEnVect component through the PopupMenu property, which is what I had done before. I double-click the TImageEnVect's OnMouseDown event to create a method stub and I have the following code:

  if Button = mbRight then
    ImageEnVect1.MouseDown( mbLeft, Shift, X, Y );


And it works! The popup menu pops up with the right-click button and the element(s) under the right-click are selected! The TPopupMenu's items are all connected to TActions, so they show the appropriate actions based on what's currently selected (via the TAction.OnUpdate handlers).

That was too simple and way fun.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 24 2014 :  07:49:50  Show Profile  Reply
Nice tip!

William Miller
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: