Formatting cells in Table Field

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DavidBurleigh
Posts: 19
Joined: Sun Apr 05, 2009 9:27 am

Formatting cells in Table Field

Post by DavidBurleigh » Sun Apr 05, 2009 9:33 am

I searched for 'formatting cells" before I posted this.

I have a table field, I want it to have two columns.
One column just big enough for a tld .eg .uk .com .cz
and the other column large enough for the country
.eg. United Kingdom Czech Republic, etc.

I have played with this thing for hours and can't find
any documentation at all, online, in the books,
nowhere. Has anyone any idea of how to set this up?

thanks
incomex@hotmail.com

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sun Apr 05, 2009 9:44 am

You're probably better off waiting for the new Data Grid that ships with the upcoming Revolution 3.5 release. It will certainly make it a lot easier to setup goodlooking tables that work the way you want to. Go to this newsletter article for a first introduction.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

DavidBurleigh
Posts: 19
Joined: Sun Apr 05, 2009 9:27 am

data grid shipping with 3.5

Post by DavidBurleigh » Sun Apr 05, 2009 10:05 am

I only have 2.9 and I don't plan on upgrading to 3.x until it's stable. I have waited 3 years to get a working version of rev to run on Ubuntu, and still it's full of bugs. It crashes my computer all the time, the select boxes pop up all over the place instead of under the control, when I close rev it takes 5 minutes for the hard drive to stop accessing which locks up my box, etc. Apparently, there is no documentation on the table field, how can this be? I have all the books including speed of thought, and I keep running into the fact that the documentation is absolutely horrid. Very few code snippets, and not even documentation on conditional statements - unbelievable.

Anyway, there must be a way to set up a grid in a field, if anyone has some actual code or a white paper that would be good; thanks.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Formatting cells in Table Field

Post by sturgis » Sun Apr 05, 2009 11:14 am

Check the dictionary for tabStops, should do what you want. At least thats whats available in 3.0, don't have 2.9, but its probably there too.

edit: probably need to look at formattedWidth also.

I think the reason its hard to find information in the dictionary specifically pertaining to the table field is first and foremost its a field that happens to have some extra properties. Best way i've found to know what to look for is look at the properties that are there, then dictionary search for those. Thats how I found the tabStop and of course to figure out how to determine the width of text, searched for width and looked at the whole list that came up.

From what you describe, you want the first field to be pretty short, then the 2nd field to take up the rest of the width of the field. So may not need formattedWidth after all, just pad enough to allow for font kerning and os font interpretation strangeness, get the width of the field (might need to adjust for the scrollbar and border, not sure, haven't actually done this yet) and then set the tabstops.

If you decide you DO want to adjust the widths live, tables treat each cell of a field as an item on a line, with the itemDelimter being tab, think you can get the right information similar to something like this.

Code: Select all

   put the formattedWidth item 1 line 1 of field "outputField" -- displays the width of the text in that cell.
-- you can do this also without the line number to find the size of the largest item of column one like so.
   put the formattedWidth item 1 of field "outputField"

That gives you a number to manipulate.
DavidBurleigh wrote:I searched for 'formatting cells" before I posted this.

I have a table field, I want it to have two columns.
One column just big enough for a tld .eg .uk .com .cz
and the other column large enough for the country
.eg. United Kingdom Czech Republic, etc.

I have played with this thing for hours and can't find
any documentation at all, online, in the books,
nowhere. Has anyone any idea of how to set this up?

thanks
incomex@hotmail.com

Post Reply