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
 Selecting Objects at a Location

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
Elemental Posted - Mar 21 2014 : 15:30:46
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?
6   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Mar 24 2014 : 07:49:50
Nice tip!

William Miller
Elemental Posted - Mar 24 2014 : 07:42:36
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.
Elemental Posted - Mar 24 2014 : 07:18:59
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.
w2m Posted - Mar 21 2014 : 15:57:52
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
Elemental Posted - Mar 21 2014 : 15:55:53
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?
w2m Posted - Mar 21 2014 : 15:48:11
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