Advanced Xailer Techniques, Drag and Drop operations
Xailer let you to perform 3 kinds of different Drag & Drop operations:
- Dragging files from the Windows explorer into the Xailer program
- Dragging elements inside a TreeView
- Dragging controls over other controls
METHOD ListBox1DropFiles( oSender, aFiles, aPoint ) CLASS ...
Aeval( aFiles, {|v| oSender:AddItem( v ) } )
RETURN Nil
In this sample, we are adding into a TListBox control, the name of files dragged into the control.
The second Drag & Drop system in Xailer is used to perform drag & drop operations among elements inside a TreeView control, you just have to set lDragDropItem property to TRUE. However, the TreeView control has some other events to give more flexibility and power to this kind of operations:
- OnBeginDragItem: This event is launches whenever you start a Drag&Drop operation between two TreeView items, recieves as a second parameter, after oSender, the TTreeViewItem object which launched the event.
- OnDragOverItem: This event is launched when, inside a Drag&Drop between items, the cursor is over a certain item. It recieves as a second parameter, after oSender, the TTreeViewItem objetct where the cursor is over. If it returns FALSE, you will see the "prohibited" cursor, indicating that is not possible to perform the D&D operation over that item.
- OnEndDragItem: This event is launched when a D&D operation is finished between items. It recieves as a second parameter, after the oSender object, two TTreeViewItem objects, one called oItemFrom, the one that launched the event, and other called oItemTo, the object where the mouse was dropped. If it returns NIL, o this event is not captured, oItemFrom will move right after oItemTo. Catching this event, is possible to reject the Drop operation or, instead of move the item after the oItemTo, it moves to a child branch of the oItemTo.
- OnBeginDrag: Is launched when there's a request to begin a D&D operation. If returns .T., this means that the D&D opearation is allowed and you notice it inmediatly because the mouse cursor changes its shape.
- OnDragOver: Is launched when the mouse cursos moves over a control, and a D&D operation has been started. It recieves as a second parameter, after oSender, the control which started the D&D operation. If returns .T. this means that the D&D operation can be performed, and you notice it because the mouse cursor shape changes to the oCursorDropYes. If this event is not trapped, or returns a value different of TRUE, the mouse cursos shape change to oCursorDropNo.
- OnEndDrag: This event is launched when you release the mouse left button over a control, and previously a D&D operation has been started. It recieves as a second parameter, after the oSender, the control which starte the D&D operation.
Please notice that the second and third ways cannot be used together, this means that you cannot perform a D&D between controls and at the same time do a D&D between TreeViewItems.
You can find a sample of D&D in the directory \Samples\DragDrop showing you the 3 ways at the same time.
0 Comments:
Post a Comment
<< Home