Member variable XbpCrt():dropZone Foundation

Determines whether the object is a drop zone.

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

The instance variable :dropZone determines whether the XbpCrt 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 XbpCrt object are ignored.

If an item is dragged over a drop zone, the XbpCrt 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.

To enable an XbpCrt object for receiving drop zone-specific events, mouse events must be enabled by a call to SetMouse(.T.)! Otherwise, items dragged via the mouse over the object are ignored.

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

PROCEDURE Main() 
 LOCAL oCrt       := SetAppWindow() 
 LOCAL cBuffer    := Space(35) 
 LOCAL GetList    := {} 
 LOCAL bDataValid := .F. 

  SetMouse( .T. ) 

  oCrt:UseShortCuts := .T. 
  oCrt:DropZone     := .T. 

  // 
  // Assign code blocks for processing the drop 
  // zone-specific notifications 
  // 
  oCrt:dragEnter    := {|aState,oData| HandleDragEnter(aState,oData,@bDataValid)} 
  oCrt:dragMotion   := {|aState,uNIL | HandleDragMotion(aState,bDataValid)} 
  oCrt:dragDrop     := {|aState,oData| HandleDragDrop(aState,oData,bDataValid)} 

  SET SCOREBOARD OFF 
  SetColor( "N/W, W+/B, B/W, R/W, W+/N" ) 
  CLS 

  @  20, 0 TO 24,79 DOUBLE 

  ColorSelect(3) 
  @ 21, 9 SAY "Simple Hybrid Mode drop zone example. The @..GET field" 
  @ 23, 9 SAY "only accepts dropped files. It rejects other formats." 
  ColorSelect(0) 

  // 
  // Create a @..GET object. The XbpCrt object 
  // only accepts files dropped over the @..GET. 
  // 
  @ 5,1 SAY "Drop File here:  " GET cBuffer PICTURE "@!" 

  DO WHILE .T. 
    READ SAVE 
    IF LastAppEvent() == xbeP_Close 
       QUIT 
    ENDIF 
    GetRefresh(GetList) 
  ENDDO    
RETURN 


// Handle xbeP_DragEnter event. The function ensures 
// that items other than files are rejected. 
FUNCTION HandleDragEnter( aState, oData, bDataValid ) 
  LOCAL oGet := GetActive() 
  LOCAL aPos := aState[2] 

   IF oData:QueryGetFormat(XBPCLPBRD_FILELIST) == .F. 
      bDataValid := .F. 
      RETURN XBP_DROPMODE_NONE 
   ENDIF 

   bDataValid := .T. 

   IF oGet == NIL .OR. ; 
      aPos[1] < oGet:Row .OR. aPos[1] > oGet:Row .OR.; 
      aPos[2] < oGet:Col .OR. aPos[2] > oGet:Col + oGet:Width -1 
      RETURN XBP_DROPMODE_NONE 
   ENDIF  
RETURN XBP_DROPMODE_COPY 


// Handle xbeP_DragMotion event. The function rejects 
// items at positions other than over the @..GET 
// object. 
FUNCTION HandleDragMotion( aState, bDataValid ) 
  LOCAL oGet := GetActive() 
  LOCAL aPos := aState[2] 

   IF oGet == NIL .OR. ; 
      aPos[1] < oGet:Row .OR. aPos[1] > oGet:Row .OR.; 
      aPos[2] < oGet:Col .OR. aPos[2] > oGet:Col + oGet:Width -1 
      RETURN XBP_DROPMODE_NONE 
   ENDIF 

   IF bDataValid == .F. 
      oGet:VarPut( "(No File!)" ) 
      oGet:SetFocus() 
      RETURN XBP_DROPMODE_NONE 
   ENDIF 
RETURN XBP_DROPMODE_COPY 


// Handle xbeP_DragDrop event. The function enters 
// the name of the first file being dropped to the 
// @..GET object's buffer for demonstrational purposes 
FUNCTION HandleDragDrop( aState,oData ) 
 LOCAL aFiles := oData:GetData( XBPCLPBRD_FILELIST ) 
 LOCAL oGet   := GetActive() 

   IF oGet == NIL 
      RETURN XBP_DROPMODE_NONE 
   ENDIF 

   oGet:VarPut( aFiles[1] ) 
   oGet:SetFocus() 
RETURN XBP_DROPMODE_COPY 


// Refresh/update the objects in the 
// GetList 
PROCEDURE GetRefresh( GetList ) 
 LOCAL i, imax := Len(GetList) 
 LOCAL oGet, nRow := Row(), nCol := Col() 

  SET CURSOR OFF 

  FOR i:=1 TO imax 
     oGet := GetList[i] 
     oGet:updateBuffer() 
  NEXT 
  SET CURSOR ON 
  SetPos( nRow, nCol ) 
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.