Page 1 of 1

Capture Cell Data on DoubleClick

Posted: Tue Jun 28, 2011 6:18 pm
by townsend
I worked with the Lesson, How Do I Get Data Associated With a Row or Column?

This works well, but in order to get the data from a specific column, you need to know the name of the column. For example, this code, from the above lesson gets the line number from dgHilitedLines and then the dgDataOfLine, to put the line into an array. Finally WITH the column name, you can grab the contents of that cell.

Code: Select all

put the dgHilitedLines of group "myGrid" into line.number
put the dgDataOfLine[line.number] of group "myGrid" into line.array
put line.array["colName"] into cellContents
I'd like to set my DataGrid to NOT "allow editing" -- then on the mouseDoubleDown message (event) -- retrieve the cell data.

How do I discern the column where the mouseDoubleDown Message (event) occurs?

Does this require editing the DataGrid Template code? Or is there an easier way?

Re: Capture Cell Data on DoubleClick

Posted: Wed Jun 29, 2011 12:16 am
by townsend
From the DataGrid User Guide:
dgColumn
- When working with a data grid table you can use the dgColumn of me in a custom template behavior
to get the name of the column the instance of the template is associated with. To use this property in
other scripts you use the target or the mousecontrol as the target as well.
What's this mean?

Beep works, when DataGrid is clicked.
Returned value of Answer is: "dgColumn".
So, this doesn't work:

Code: Select all

on dgMouseDown
     beep
     answer dgColumn of group "myGrid"
end dgMouseDown
Can someone point me in the right direction?

Re: Capture Cell Data on DoubleClick

Posted: Wed Jun 29, 2011 12:33 pm
by Klaus
Hi townsend,

this should work for your, put it into the script of your datagrid:

Code: Select all

on mousedoubleup
     answer the dgColumn of the target
end mousedoubleup
"the dgColumn of XYZ" is not a Datagrid (group) property, but a property of an object inside of the datagrid!

Best

Klaus

Re: Capture Cell Data on DoubleClick

Posted: Wed Jun 29, 2011 2:55 pm
by townsend
Thanks Klaus!

Nice. That works.

I'll add the target my list of special LIveCode functions-- like the result and it.