Had to send again because message was too big.
Hi all.
Following is code I have in the data grid object's script. Essentially am
attempting to drag a value in a column to another place in the column to
rearrange the values.
When I execute a drag and drop within a column, Revolution goes beachball on
me. I originally thought it was the command to set the dgText that was causing
the beachball, but no! Using GLX2 and stepping through the code, I discovered
that the beachball happens when DragDrop ends after returning from the dispatch
call to ProcessDrop! (see code comments)
Anyone have a clue?
Bob
--> Data Grid Handlers
on dragStart
put the dgDataControl of the target into theDataControl
## Watch out for dragging on the header
if theDataControl is empty then pass dragStart
## Get Data Grid index of control that was clicked on
put the dgDataControl of the target into theTargetLongID
put the dgIndex of the dgDataControl of the target into theIndex
## Tell Data Grid to set the dragImage to the row
## that theIndex is associated with
set the dgDragImageIndex of me to theIndex
## Set the dragData["private"] so that drag operation
## begins
set the dragData["private"] to the short name of theDataControl & space &\
theIndex
set the dgTrackDragReorder[theIndex] of me to true
end dragStart
on DragDrop
-- Get the values we stored from dragStart
put dragData["private"] into theDropSource
-- Store the values for the target
put the dgIndex of the dgDatacontrol of the target into theIndex
put the short name of the dgDataControl of the target & space &\
theIndex into theDropTarget
-- theDropSource and theDropTarget now contain a space delimited list
-- of the column name, the displayed row, and the data index
-- for the source and the target
if theDropSource = theDropTarget then
-- Do nothing
exit to top
end if
dispatch processdrop with theDropSource, theDropTarget
end DragDrop -- THIS BEACHBALLS REVOLUTION!!!
--> My Handlers
on processdrop theDropSource, theDropTarget
set the itemdelimiter to tab
put word 1 of theDropSource into theSourceColumn
put word 3 of theDropSource into theSourceRow
put word 1 of theDropTarget into theTargetColumn
put word 3 of theDropTarget into theTargetRow
if theSourceColumn = theTargetColumn then
--> *Rearrange items
-- get the data
get the dgText of me
put it into theData
-- which column
if theSourceColumn = "prifields" then
put 1 into theColumn
else
put 3 into theColumn
end if
-- Store the source value
put item theColumn of line theSourceRow of theData into theSourceData
-- Determine the repeat loop direction
if theSourceRow < theTargetRow then
-- rearrange forward
repeat with theRow = theSourceRow+1 to theTargetRow
put item theColumn of line theRow of theData into \
item theColumn of line theRow-1 of theData
end repeat
-- Drop the source value into the target
put theSourceData into item theColumn of line theTargetRow of
theData
else
-- rearrange backwards
repeat with theRow = theSourceRow-1 down to theTargetRow
put item theColumn of line theRow of theData into \
item theColumn of line theRow+1 of theData
end repeat
-- Drop the source value into the target
put theSourceData into item theColumn of line theTargetRow of
theData
end if
else
--> *Link items
end if
breakpoint
-- save the data
set the itemdelimiter to comma
set the dgText of me to theData
-- At this point theData looks good! The values for the column
-- source and target are swapped and if you step through the code
-- the data grid has been updated!
end processdrop_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution