Page 2 of 2

Re: Accesing text of a cell in table field by clicking on it

Posted: Fri Jan 24, 2020 7:16 pm
by dunbarx
Hi.

Good. But have you accounted for the fact that you may want to increase the number of columns of your table field? The tabstops you manually set earlier will break the handler, because it always expects that the number of explicit tabStops is the same as the number of columns.

Think about adding something like this to your stack, so that whenever you increase the number of columns, there will be an explicit tabStop for each:

Code: Select all

on mouseUp
   get fld 1
   set the itemDel to tab
   put the number of items of line 1 of it into numTabs
   
   set the itemDel to ","
   put the tabStops of fld 1 into stopList
   if the number of items of stopList < numTabs then
      put item -1 of stopList - item -2 of stopList into tDiff
      repeat with y = the number of items of stopList to numTabs
         put "," & the last item of stopList + tDiff after stopList
      end repeat
   end if
   set the tabStops of fld 1 to stopList
end mouseUp
If you reduce the "width" of the field, the extras will be ignored. If you change the widths of any of the columns, it will not matter.

Craig