How to find the column and row of a basic tableField

Pi Digital sean at pidigital.co.uk
Wed Apr 1 18:52:44 EDT 2020


Thanks Bernd. 

This only works if there is already data in the field. If you put empty into the field it produces no results. In those instances you are forced to get an x,y clickLoc and use the tabstops and textHeight to hard code the result. 

The revTableLibrary was last modified in 2015 from your recommendations and pulls. Notable is the ones in revCalculateCellLoc and revCalculateCellRect. Interestingly in revCalculateCellLoc there is a couple of lines that set cREVTable[“currentxcell”] and [“currentycell”] of the object. 

Using:
Put cRevTable[“currentxcell”],cRevTable[“currentycell”] into tCellIndex
Works a charm. 

To make this work you do need to have cellEdit enabled but to avoid having it actually enable editing the text, in the mouseup just have a ‘select nothing’ to immediately exit the field. That way you only return the xy index and can use other means to add in or collect cell data. 

This is far less convoluted and exactly what I was looking for. None of this faffing around with huge lines of code. LiveCode is supposed to be EASY and almost instinctive. This is pretty close. 

It’s a real shame that these are not visible in the property inspector as standard properties and not even in the customProperties cRevTable until you have clicked into one of the cells in runtime when it populate the custom set.

It’s even more of a shame that this is not documented anywhere, in the dictionary, guide, lessons, tutorials. It’s practically lost to obscurity in the forums too only being found if I search for currentxcell specifically. I only found it by hacking through all of the object library code of the IDE stacks. 

This definitely make the table field object far more useful, though. 

Sean Cole
Pi Digital Productions Ltd


More information about the use-livecode mailing list