Member variable XbpWindow():dropZone Foundation

Determines whether the object is a drop zone.

Attribute: EXPORTED
Data type: Logical (.F.)
Description

The instance variable :dropZone determines whether the XbpWindow object accepts items dropped during drag'n drop operations. If an Xbase++ application assigns the value .T. (true), the object serves as a target for drag operations. If an item is being dragged over a drop zone, a different type of cursor is displayed as a visual reference for the user. If .F. (false) is assigned to :dropZone, items dropped on the XbpWindow object are ignored.

If an item is dragged over a drop zone, the XbpWindow object notifies the application by sending messages as soon as the item is being dragged inside the object's bounding rectangle. The messages sent allow the application to take action depending on both the type of item being dragged as well as on the operations performed with it. See the callbacks :dragEnter(), :dragMotion(), :dragLeave(), :dragDrop() for further information.

 // 
 // Example for implementing event processing for a drop zone. 
 // The example accepts only files dragged over from the 
 // Windows Shell. Other items, such as text or images, are 
 // ignored. 
 // 
 #include "AppEvent.CH" 
 #include "XBP.CH" 

 #define CRLF    Chr(13) + Chr(10) 

 PROCEDURE Main() 
  LOCAL oDlg 
  LOCAL oMLE 
  LOCAL nEvent, mp1, mp2, oXbp 

   // 
   // Create application's main dialog 
   // 
   oDlg := XbpDialog():new( Appdesktop() ) 
   oDlg:title 	  := "Drop Zone Example" 
   oDlg:taskList := .T. 
   oDlg:close    := {|| PostAppEvent(xbeP_Quit,,, oDlg) } 
   oDlg:create( ,, {50,50}, {600,400} ) 

   // 
   // Create an XbpMLE object that the can 
   // accept files dropped into it. Assign 
   // code blocks for handling the respective 
   // notifications 
   // 
   oMLE  := XbpMLE():new( oDlg:drawingArea ) 
   oMLE:dropZone  := .T. 
   oMLE:dragEnter := {|aState,oData| HandleDragEnter(aState,oData,oMLE)} 
   oMLE:dragDrop  := {|aState,oData| HandleDragDrop(aState,oData,oMLE)} 
   oMLE:create( ,, {5,5},{400,200} ) 

   oMLE:SetData( "DROP FILES HERE..." + CRLF + CRLF ) 

   nEvent := xbe_None 
   DO WHILE nEvent != xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:handleEvent( nEvent, mp1, mp2 ) 
   ENDDO 
    
   oDlg:destroy() 
 RETURN 


 // Handle xbeP_DragEnter event. The function ensures 
 // that items other than files are rejected 
 FUNCTION HandleDragEnter( aState,oData,oMLE ) 
   LOCAL cBuffer 

    IF oData:QueryGetFormat(XBPCLPBRD_FILELIST) == .T. 
       RETURN XBP_DROPMODE_COPY 
    ENDIF 

    cBuffer := oMLE:GetData() 
    cBuffer += "(Sorry, sample only accepts files!)" + CRLF 
    oMLE:SetData( cBuffer ) 
 RETURN XBP_DROPMODE_NONE 


 // Handle xbeP_DragDrop event. The function enters 
 // the name(s) of the file(s) being dropped to the 
 // XbpMLE's buffer for demonstrational purposes 
 FUNCTION HandleDragDrop( aState,oData,oMLE ) 
   LOCAL aFiles  := oData:GetData( XBPCLPBRD_FILELIST ) 
   LOCAL i 
   LOCAL cBuffer := oMLE:GetData() 

     FOR i:=1 TO Len(aFiles) 
        cBuffer += aFiles[i] + CRLF 
     NEXT 

     oMLE:SetData( cBuffer ) 
 RETURN XBP_DROPMODE_COPY 


 // Overloaded AppSys() procedure to prevent 
 // creation of the default XbpCrt window 
 PROCEDURE AppSys() 
 RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.