Capture Cell Data on DoubleClick

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Capture Cell Data on DoubleClick

Post by townsend » Tue Jun 28, 2011 6:18 pm

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?

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Capture Cell Data on DoubleClick

Post by townsend » Wed Jun 29, 2011 12:16 am

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?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Capture Cell Data on DoubleClick

Post by Klaus » Wed Jun 29, 2011 12:33 pm

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

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Capture Cell Data on DoubleClick

Post by townsend » Wed Jun 29, 2011 2:55 pm

Thanks Klaus!

Nice. That works.

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

Post Reply