DragDrop and the DragDestination
bobs at twft.com
Thu Jan 20 20:25:30 EST 2011
Well I don't want to take a lot of anyone's time anymore. I thought it would be a simple matter to get the value of a cell in one dataGrid and put it into the cell of another, but this is proving to be a beatch.
In your experiment 19, you use setDataOfLine to modify the value in the color column in the row dropped on to. Okay I get it, but since I am trying to put the value into the first empty cell in that column I am using setDataOfIndex because the cell may not be visible, should be no problem.
But here's the problem: The destination data grid starts out empty, so all my calls to the index of anything is going to be zero. Even if I fudge the index to be one, if there is no objects for line 1, I cannot set the dataOfAnything.
In retrospect, I think the way a datagrid should have been implemented is, there should ALWAYS be objects replicated for as many rows as are visible. This way, I could get and set values for any visible line without having to worry about this gotcha. I can see though that if someone scrolled the data grid, you would be faced with having to add more rows, and then would you delete them if the user scrolled up?
Maybe the solution would be to have at least one empty row at the bottom of the datagrid so there would be objects to work with. Or else, the data grid api could be modified so that if I set the dataOfIndex or dataOfLine larger than dgNumberOfLines, it would insert as many blank lines as needed to get me there. Food for thought.
I think what I will do, is instead of setting dgText to empty when I want to clear the datagrid, I will set the contents to a tab delimited list of empty lines for as many rows as are displayed. That will get around this issue for now.
I hope people see my issue. It is like having a spreadsheet that constantly threw errors when I used an empty cell as a reference, simply because there was nothing in it.
More information about the Use-livecode