BBjGrid::setDragAccept

Description

Sets whether the BBjGrid will accept drag and drop operations.

Syntax

Return Value

Method

void

setDragAccept(boolean drag)

Parameters

Variable

Description

drag

Sets whether the grid will accept drag and drop operations.

0 = No drag and drop operation

1 = Drag and drop operation

Return Value

None.

Remarks

If drag and drop operation is set ON, the user can click on a cell and drag to another cell and release, copying the contents from the first cell into the second cell. The grid handles drag and drop operations if this option is set. By default, drag and drop operations are not allowed.

setDragAccept(1) causes the following behavior:

1.

If the user begins a drag gesture while cursor is on the grid, BBj fires a BBjGridMouseDragEvent and displays the drag cursor.

2.

In 4.03- If the user is executing a drag gesture and releases the mouse button while over the grid, then BBj fires a BBjGridMouseUpEvent rather than a BBjGridDragDropEvent. The grid does not accept the dragged item and the content of the grid does not change.

 

In BBj 6.0and higher - If the user is executing a drag gesture and releases the mouse button while over the grid, then BBj will accept the dragged item and fires a BBjGridDragDropEvent rather than a BBjGridMouseUpEvent. If the dragged item is a string, the content of the grid will be changed.

When setDragAccept(1) is specified, drag/drop actions will always be allowed, even if the grid is not otherwise editable. The BBjGridDragDropEvent can be used to selectively accept or reject drag/drop actions, as shown in the example program.

Example

rem ' BBjGrid::setDragAccept
sysgui = unt
open (sysgui) "X0"
sysgui! = bbjapi().getSysGui()
title$ = "BBjGrid::setDragAccept"
window! = sysgui!.addWindow(50,50,400,400,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
rows = 25
cols = 2
grid! = window!.addGrid(101,25,25,350,300,$81c8$,rows,cols)
grid!.setRowHeight(30)
grid!.setFitToGrid(1)
grid!.setLineColor(BBjColor.LIGHT_GRAY)
for row = 0 to rows-1
 for col = 0 to cols-1
  text$ = "row " + str(row) + ", col " + str(col)
  grid!.setCellText(row,col,text$)
 next col
next row
grid!.setEditOnKeyPress(1)
grid!.setSnapToRowHeight(0)
grid!.setCallback(grid!.ON_GRID_CELL_MODIFY,"event")
grid!.setCallback(grid!.ON_GRID_MOUSE_DRAG,"event")
grid!.setCallback(grid!.ON_GRID_DRAG_DROP,"dragdrop")
grid!.setCallback(grid!.ON_GRID_EDIT_START,"event")
grid!.setCallback(grid!.ON_GRID_EDIT_STOP,"event")
dragdrop! = window!.addCheckBox(102,25,350,150,25,"setDragAccept",$$)
dragdrop!.setCallback(dragdrop!.ON_CHECK_CHANGE,"setDragAccept")
editable! = window!.addCheckBox(103,200,350,150,25,"setEditable",$$)
editable!.setCallback(editable!.ON_CHECK_CHANGE,"setEditable")
process_events
eoj:
  release
resize:
  event! = sysgui!.getLastEvent()
  grid!.setSize(event!.getWidth()-50,event!.getHeight()-100)
  dragdrop!.setLocation(dragdrop!.getX(),event!.getHeight()-50)
  editable!.setLocation(editable!.getX(),event!.getHeight()-50)
return
setDragAccept:
  event! = sysgui!.getLastEvent()
  grid!.setDragEnabled(event!.isChecked())
  grid!.setDragAccept(event!.isChecked())
  grid!.setMouseCapture(event!.isChecked())
return
setEditable:
  event! = sysgui!.getLastEvent()
  grid!.setEditable(event!.isChecked())
return
dragdrop:
  gosub event
  row = event!.getRow()
  col = event!.getColumn()
  text$ = event!.getOriginalText()
  grid!.setCellBackColor(row,col,BBjColor.YELLOW)
  if grid!.isEditable() then
     i = msgbox("Drag/Drop Allowed")
  else
     i = msgbox("Drag/Drop Rejected")
     grid!.setCellText(row,col,text$)
  endif
  grid!.setCellBackColor(row,col,BBjColor.WHITE)
return
event:
  event! = sysgui!.getLastEvent()
  print event!.getEventName(),event!.getRow(),event!.getColumn()
  print " getOriginalText: ",event!.getOriginalText(err=*next)
  print " getOldText: ",event!.getOldText(err=*next)
  print " getEditText: ",event!.getEditText(err=*next)
  print " getNewText: ",event!.getNewText(err=*next)
  print " getValue: ",event!.getValue(err=*next)
  print ""
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.