9. Advanced AJAX
Moveable Controls (a.k.a. Drag and Drop)
<< Porting Code to the Client Side   |   Back to Main   |   Automatic Scrolling >>

View Source
will open in a new window
Making a Control Moveable
Here we demonstrate the moveable controls capability of Qcodo, also known as "Drag and Drop".

All QControls are capable of being moved. However, only QLabel and QPanel controls are capable of being "move handles". A "move handle" is anything that you can click which can begin execution of a move. For example, in a standard GUI (e.g. Windows or the Mac OS), you cannot just click anywhere on a window to make the window move. You can only click on a window's Title Bar to get that window to move. So while the window, itself, is a moveable object, the window's Title Bar is the "move handle". And in this case, the "move handle" is targetted to move itself as well as the window it is connected to.

The QLabel and QPanel controls have an AddControlToMove method defined on it, which takes in a QControl as a parameter. Making this call will cause your QLabel or QPanel to become a "move handle". And the QControl you pass in will be added as a control that will be moved by it.

In this example, we define a simple QPanel, and we add itself as a moveable control so that you can click on the panel and move it around.
You can click on me to drag me around.