DataGrid CloseFieldEditor: row and column of edited cell

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ElZitouni
Posts: 33
Joined: Sun Oct 14, 2012 10:43 pm

DataGrid CloseFieldEditor: row and column of edited cell

Post by ElZitouni » Sun Jan 22, 2017 5:15 am

Hello: the CloseFIeldEditor message is sent to a datagrid script when the user changed the contents of a table cell. How can I determine the row and column of the cell that has been changed when that message is sent? Thanks, Olli.

ElZitouni
Posts: 33
Joined: Sun Oct 14, 2012 10:43 pm

Re: DataGrid CloseFieldEditor: row and column of edited cell

Post by ElZitouni » Sun Jan 22, 2017 5:31 pm

Hello: for those pondering at some point the same question, this here is a possible solution, at which I arrived after searching the forum and the datagrid API ... could have done that before posting the question, couldn't I?

This code resides in the group script of my datagrid. First, the preOpenFieldEditor message is caught and the cLastClickedCell of the datagrid set to the target of the mouse double click that triggered the opening of a field editor. this property is then used to access the index and key of the cell that changed, ie., upon receipt of the CloseFieldEditor message. With this information at hand, one knows precisely what entry was modified.

Code: Select all

on preOpenFieldEditor pFieldEditor
     set the cLastClickedCell of me to the long name of the target
end preOpenFieldEditor


on CloseFieldEditor pFieldEditor
     local tIndex, tKey
     
     put the dgIndex of the cLastClickedCell of me into tIndex
     put the dgColumn of the cLastClickedCell of me into tKey
end CloseFieldEditor

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: DataGrid CloseFieldEditor: row and column of edited cell

Post by MaxV » Thu Feb 09, 2017 12:57 pm

In order to get row, column and text typed you may use just:

Code: Select all

on CloseFieldEditor pFieldEditor
   put the dgIndex of the target into theRow
   put the dgColumn of the target into theColumnBeingEdited
   put the text of pFieldEditor into theNewText    
end CloseFieldEditor
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”