| 1 | # Dragging Test |
| 2 | |
| 3 | Test two approaches to implement dragging in CGE: |
| 4 | |
| 5 | 1. Just watch `Motion` events (e.g. by overriding `TCastleView.Motion`), and subtract `new mouse position - old mouse position`. |
| 6 | |
| 7 | This is simple, and makes sense if |
| 8 | |
| 9 | - uses can see the mouse cursor position |
| 10 | - and the dragging area is naturally limited to the window. |
| 11 | |
| 12 | E.g. this makes sense when you implement drag-and-drop. |
| 13 | |
| 14 | 2. Use the same logic as _mouse look_. In this case the mouse cursor should be hidden, and you use `TCastleContainer.MouseLookDelta` and friends to |
| 15 | |
| 16 | - read mouse motion movement, |
| 17 | - and keep the mouse position around the middle of the window (to pretend that the dragging area is infinite). |
| 18 | |
| 19 | This makes sense if you want the movement of something to *not* be limited by window borders. |
| 20 | |
| 21 | Using [Castle Game Engine](https://castle-engine.io/). |
| 22 | |
| 23 | ## Building |
| 24 | |
| 25 | Compile by: |
| 26 | |
| 27 | - [CGE editor](https://castle-engine.io/editor). Just use menu items _"Compile"_ or _"Compile And Run"_. |
| 28 | |
| 29 | - Or use [CGE command-line build tool](https://castle-engine.io/build_tool). Run `castle-engine compile` in this directory. |
| 30 | |
| 31 | - Or use [Lazarus](https://www.lazarus-ide.org/). Open in Lazarus `dragging_test_standalone.lpi` file and compile / run from Lazarus. Make sure to first register [CGE Lazarus packages](https://castle-engine.io/lazarus). |
| 32 | |
| 33 | - Or use [Delphi](https://www.embarcadero.com/products/Delphi). Open in Delphi `dragging_test_standalone.dproj` file and compile / run from Delphi. See [CGE and Delphi](https://castle-engine.io/delphi) documentation for details. |