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

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Fri Jan 24, 2020 7:16 pm

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

Post Reply