Help moving an object to mouse up - Forum

Forum Navigation
VisualNEO Products: Web, Win and PixelNEO
You need to log in to create posts and topics.

Help moving an object to mouse up

Please I need help looking for a solution to my example. Where you move the pencil the image would move when Mouse UP.

 

Hola de nuevo, veréis, intento desplazar un objeto al lugar donde  desplace otro al soltar el click del ratón, pero no lo consigo, os pido ayuda. Gracias.

Os dejo un zip de respaldo del ejemplo que os quiero mostrar.

Donde desplaces el lápiz se deberia desplazar la imagen al soltar el raton

Uploaded files:
  • You need to login to have access to uploads.

@joaquinfdez

Where you move the pencil the image would move when Mouse UP.

Change the second line of code for the click event for PushButton1 to ...

neoDragSetEvents "Image3" "" "" "neoline"

... this makes the red line (with the arrow head) only refresh when you finish the drag process (i.e. mouse up at the end of the drag).

If this is not what you meant, please provide details of what you want.

Ok @gaev thanks , Thats is not what I want to do. I really need the image of man once clicked to go the pencil position.

Excuse me if I have not expressed myself well in English language.

@joaquinfdez

I really need the image of man once clicked to go the pencil position.

a) your click event for PushButton1 should look like this ...

neoDragInit "Image3"
neoDragSetEvents "Image3" "" "neoline" "neolineDragEnd"
neoLineInit "Image1" "Image3" "red" 5

b) create a new subroutine with the name of neolineDragEnd and place this code in it ...

neoDragGetPositionX "Image3" [Image3Left]
neoDragGetPositionY "Image3" [Image3Top]
AlertBox "Image3" "[Image3Left]<br/>[Image3Top]" ""

c) now, when you run the App, click the PushButton, Drag and Drop the pencil ... the AlertBox will tell you the new (left and top) positions of the pencil.

d) you can use this command ...

MoveObject "object name" "left" "top"

... to move Image1 to the [Image3Left] and [Image3Top] location (may have to remove the decimal points first).

However, I am not sure what you want to do with the pencil at this time ...

- move it back to its original position ?

- keep it there (on top of or below the other mage) ?

... please advise.

Excuse me if I have not expressed myself well in English language.

LOL ... your English is much better than my Spanish (currently at Level Zero) ... uno, dos, tres, cuatro, muchas gracias, amigo,  hola, gringo, loco ... the 3 (Mexican) peppers (jalapeno, habanero, cayenne) ... and of course go-ooooooooo-al.

Jajaja!! Thanks for your Help @gaev

I try to do all you write me .
Thanks you Very much  !!
Regards

....

I did it and it worked very well !! I am very grateful to you @gaev

@gaev look what happen :  The Image of man it is  on place left=13 and Top = 237  but when I move the mouse dragging the pencil and relase the mouse in the same place of Image of man , the values are different.

when you said: .. to move Image1 to the [Image3Left] and [Image3Top] location (may have to remove the decimal points first).

I really  don´t know what you mean exactly

Could you tell me why that happens? Because When I apply those values to the Move command , the image appears in a totally different place. Try it and you will see it .

I apologize for bothering you again.

@joaquinfdez

when I move the mouse dragging the pencil and relase the mouse in the same place of Image of man , the values are different.

I see what you mean.

I did some experiments and captured the reported values; here is my finding ...

a) the Y position is being reported correctly; let me know your screen size (width and height) if you are experiencing incorrect values)

b) it seems that the X position being reported is relative to the left of your screen (not the left border of the work space) ... on my laptop, this is a difference of about 444 px.

I am not sure why there is this discrepancy ...

- a defect ?
- what will happen if the App is run as a native App in (say) a smart phone (or in a device with a different screen size)

c) I can calibrate this difference (by capturing this value in the subroutine that is invoked when the Drag operation is started the first time).

Before I do it, perhaps @luishp can throw some light on ...

- the unexpected results.

- the fact that, after the Drag operation is initiated, GetObjectInfo does not return the (new) dropped position of the dragged object.

 

 

Hi @gaev and @joaquinfdez

Please take a look at the attached sample.
I know this is not easy due to two reasons:

  1. The way neoDrag plugin returns object position (relative to the browser window).
  2. The Page is by default centered on screen.

To solve this we need to get the Page position relative to the screen using:

BeginJS
   var rect = document.getElementById("NewPage").getBoundingClientRect();
   $App.PageLeft=rect.left;
   $App.PageTop=rect.top;
EndJS

Then we can substract the Page Left and Top values from the pencil image Left and Top values, so we get the position to move the boy image. Please let me know if you have any doubt.

Regards.

Uploaded files:
  • You need to login to have access to uploads.

@luishp

This is what I meant by "calibration" in my previous post.

I have not had time to download/run your sample (just got up and have to prepare for a ZOOM meeting with my old classmates) ... but if I may make a suggestion, it might be easier for the developers if there were two new plugin commands e.g. ...

neoDragGetDisplacementX
neoDragGetDisplacementY

... which would return the values AFTER subtracting the Page Left and Top values from the pencil image Left and Top values.

Also, when you have some time, perhaps you can look into the other observation in my earlier post i.e. after the Drag operation is initiated, GetObjectInfo does not return the (new) dropped position of the dragged object.

WAOoo!! I m very impressed and very grateful.

This is what I was trying to do.

Thanks @luishp and @gaev

Open chat
1
Do you need more info?
Hi, do you have any doubt?