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
 Drag/Drop Ordering
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

cpstevenc

USA
125 Posts

Posted - Nov 13 2012 :  09:03:42  Show Profile  Reply
Delphi 7 - ImageEN v4.1.0

I am using the Drag & Drop demo as my base.

Basically I want an image bar with say 5 images for example

I want the user to be able to change the ordering around.

The example "works" but for some testing, people say it doesn't
seem to work like one would think.

They have to select the image (left click and let go) so its highlighted, then they drag and drop to move it.
Is there a way to get it so when they left click and hold down to drag over in one process, that it selects that image first then starts the dragging process?

I've tried doing some things but failed so far.

cpstevenc

USA
125 Posts

Posted - Nov 13 2012 :  09:07:30  Show Profile  Reply
Forgot to mention if they select an image by clicking and letting go, and then they click on another image and start dragging it right away, it seems the index of the image being dragged is the one that is highlighted.. not the actual one you clicked on.

Here is an example of my drop event


   if Source = ImageEnMView2 then
    begin
     idx := ImageEnMView2.SelectedImage; // <-- this is issue
   //uses whatever image highlighted as selected, clicking and
  //dragging right away, causes this to give bad 
  // results by moving the wrong image.

     im  := ImageEnMView2.InsertingPoint(X, Y);
     if (idx > -1) and (im > -1)
      and (im <= ImageEnMView2.ImageCount)
       and (idx <= ImageEnMView2.ImageCount)
       then
        begin
         ImageEnMView2.MoveSelectedImagesTo(im);
         ImageEnMView2.IEEndDrag;
         ImageEnMView2.Update;
        end;
    end;
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 13 2012 :  16:21:19  Show Profile  Reply
I believe there is a demo in Samples that shows how to do this... it is in the ... samples\dragdrop\multiview2 folder.

This code starts the drag operation in MouseMove and ends the drag in the EndDrag event. It also draws a horzontal red line at the insertion point:
procedure TForm1.ImageEnMView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
  iIndex: integer;
begin
  ImageEnMView1.MultiSelectSortList; // selection order is not important
  iIndex := ImageEnMView1.InsertingPoint(X, Y);
  ImageEnMView1.MoveSelectedImagesTo(iIndex);
end;

procedure TForm1.ImageEnMView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState;
  var Accept: Boolean);
var
  iIndex: integer;
  imgX, imgY: integer;
begin
  if Source = ImageEnMView1 then
  begin
    Accept := True;
    iIndex := ImageEnMView1.InsertingPoint(x, y);
    imgX := ImageEnMView1.ImageX[iIndex] - ImageEnMView1.ViewX;
    imgY := ImageEnMView1.ImageY[iIndex] - ImageEnMView1.ViewY;
    ImageEnMView1.Paint;
    // draw a horzontal red line to show the insertion point
    with ImageEnMView1.GetCanvas do
    begin
      Pen.Color := clRed;
      Pen.Width := ImageEnMView1.SelectionWidth;
      MoveTo(imgX + 10, imgY);
      LineTo(imgX + ImageEnMView1.ThumbWidth - 10, imgY);
    end;
  end;
end;

procedure TForm1.ImageEnMView1EndDrag(Sender, Target: TObject; X, Y: Integer);
begin
  // stop dragging
  ImageEnMView1.IEEndDrag;
  ImageEnMView1.MouseInteract := [mmiSelect];
end;

procedure TForm1.ImageEnMView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if (ssLeft in Shift) then
  begin
    ImageEnMView1.MouseInteract := [];
    // initiate dragging
    ImageEnMView1.IEBeginDrag(true, -1);
  end;
wnd;


108.98 KB Selected image is blue and insertion point is red
102.89 KB Image showning images after drop
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

cpstevenc

USA
125 Posts

Posted - Nov 13 2012 :  21:51:26  Show Profile  Reply
thanks I'll check it out. I know at least in my version of ImageEN that demo doesn't look like that. Just has the image bar down the left, and image view on the right.. rest of that is not there..
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 14 2012 :  06:49:57  Show Profile  Reply
Thats because it is a new demo from my Ebook.

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

cpstevenc

USA
125 Posts

Posted - Nov 14 2012 :  08:02:32  Show Profile  Reply
"They have to select the image (left click and let go) so its highlighted, then they drag and drop to move it.
Is there a way to get it so when they left click and hold down to drag over in one process, that it selects that image first then starts the dragging process?"



Any idea on this part? If you already selected an image earlier.. then you click and hold over another image and move around, it does not actually select it at all, and when you let go, it moves the old image that was selected.

It needs to invoke the selection when you left click and hold down.


Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 14 2012 :  08:17:33  Show Profile  Reply
I do not see nor understand what you describe here. A left click and holding left button down and drag to new position moves the image as expected. When dragging the image you should not just click and drag over an image, rather click and drag using the red line as the insertion point.

You do not have to select and let go to highlite the image with the code I provided... just click, drag and release.

"It needs to invoke the selection when you left click and hold down."
It does this. When you click and hold the image is selected, then while holding you move the mouse to insert the image at a new insert point. As soon as you move the Drag Event begins.

Did you try the code I provided?

The code I provided works when GridWidth = 1 as shown in the images posted. What is your grid width?

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

cpstevenc

USA
125 Posts

Posted - Nov 15 2012 :  15:31:50  Show Profile  Reply
My gridwidth is 0.. so one row of images.

I used your example. The line deal works perfectly and all.

The problem is still where i select an image via click and let go. Then click on it again and hold and drag it somewhere to reorder. that works.

Then if my next steps was to click and hold down on another image to move it, and let go, it actually moves the previous image that was moved. As it still has the selection highlighted box around it still.

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