Cell formatting in Table Field

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

synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

Cell formatting in Table Field

Post by synto » Tue Aug 20, 2019 11:01 am

Hi,
I want to make a horizontal calendar with a table field with 365 cells that user can scroll from 01/01 to 31/12.
Each cell is a day, and the user can click on every cell to display a form, and entering some infos about the choosen day.

I want to color every day according to the information entered.

The table field has a CellFormatting option, but i don't find any information about it.
How can i use it to format every cell of my table ?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Tue Aug 20, 2019 1:54 pm

Hi.

A table field is just a field with certain properties. You can set the backColor (or the textColor) of, say, line 20 of that field to, say, "red".

You may want to change the margin properties so that the backColor completely fills the "cell". Some other tweaks will likely be necessary as well...

So when you display your "form", just set the properties of the line of interest.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Tue Aug 20, 2019 2:31 pm

I just saw that you wanted a horizontal calendar, so the natural parsing available with lines is not valid. All the data resides in line 1, no?

Have to play with this for a while, but at least you can do odd things like:

Code: Select all

on mouseDown
   put the clickchunk into tChunk
   set the itemDel to tab
  do " set the backColor of tChunk to red"
end mouseDown
But I am not sure there is a way to set the backColor of a "cell". That is, after all, only a region of the field as determined by the tabStop of that "cell". You may have to overlay a blendLeveled control of the "width" of the "cell", located with a bit of math.

Anyone know how to set the backColor of item 3 of a table field, items set to tabs?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Tue Aug 20, 2019 2:41 pm

On another note, since you mention it, I have no idea what the cellFormat property is. It does not appear in the dictionary.

Sounds interesting, though.

Anyone?

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cell formatting in Table Field

Post by bogs » Tue Aug 20, 2019 3:11 pm

dunbarx wrote:
Tue Aug 20, 2019 2:31 pm
Anyone know how to set the backColor of item 3 of a table field, items set to tabs?
i'm sure that was a joke :P but, just in case it wasn't a joke...
tableBackColorCell.png
The item in your cart is now blue...
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Tue Aug 20, 2019 3:42 pm

Boggsie.

No joke. i asked for the entire cell, not just the text within,

Craigsie.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cell formatting in Table Field

Post by bogs » Tue Aug 20, 2019 3:55 pm

My bad, comprehension hasn't kicked in yet :wink:
Image

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Cell formatting in Table Field

Post by Klaus » Tue Aug 20, 2019 5:21 pm

Too bad there is few to no documentation for the TABLE field. :(
The "revtablelibrary" scripts look really promising!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Tue Aug 20, 2019 9:36 pm

So I guess that in order to colorize a full "cell", one would have to overlay, say, a button with a moderate blendLevel, size it and place it by keeping track of the hScroll and calculating the tabStops of the item of interest?

Craig

synto
Posts: 40
Joined: Thu Jul 18, 2019 9:31 am
Location: Paris, Fr

Re: Cell formatting in Table Field

Post by synto » Wed Aug 21, 2019 9:00 am

Thanks to all for the help !

Actually, the calendar is contained in a table with only one very long line that the user can scroll.

The idea of using some clickable blendLeveled object in front of the table field is very smart, but i have to check if this will not create too much object on the card. And too much mouseUp script too...

However, perhaps something with the clickchunk keyword with the backcolor property of item X in line Y is a beginning of a solution. I didn't know how to get the day clicked. This is a beginning...

In fact, on this calendar, each day must visually indicate if, for this day, information has been totally entered, partially entered, no information entered (for example, icon, background, anything else... in green, orange, white).
Perhaps i can just display the border of cells in the appropriate color...
Perhaps i can overlay a table field with same structure and with some colorized graphical ASCII text like circle, square,...

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cell formatting in Table Field

Post by bogs » Wed Aug 21, 2019 11:22 am

synto wrote:
Wed Aug 21, 2019 9:00 am
Perhaps i can just display the border of cells in the appropriate color...
You can change the borderColor to produce cell borders of a specific color, but you can't do that on a 'per cell' basis, it is all or nothing (far as I can tell).
cellBorderColoring.png
Don't cross my borders...
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Wed Aug 21, 2019 2:06 pm

Hi.

It is certainly possible to do all you want. But because it requires more from a table field than is natively within that field, kluges will be required.

Just one more time (as I mistakenly thought at the top of this thread), much is simplified if the scroll can be vertical instead of horizontal. Is this a possibility at all?

If not, we start kluging.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Cell formatting in Table Field

Post by bogs » Wed Aug 21, 2019 2:08 pm

OOOoooo, this should be good! :D
(taking seat in back of class)
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Wed Aug 21, 2019 2:12 pm

Try this in the script of a table field where there is data in each "cell" of the first line of that field:

Code: Select all

on mouseDown
   put the clickchunk into tChunk
    do " set the backColor of tChunk to blue"
end mouseDown
Click on one or more "cells". Is this enough of a marker? The choice of color can be selected based on your own criteria.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cell formatting in Table Field

Post by dunbarx » Wed Aug 21, 2019 6:11 pm

You don't even need to use the "do" construction:

Code: Select all

on mouseDown
 if the clickText <> "" then  set the backColor of the clickChunk  to "red"
end mouseDown
You need to check the clickText; the problem with this sort of kluge is that the "cell" is not accessible as a whole the way we want it, and it matters when you are trying to pin it down with the clickChunk.

Anyway, is this just too much to ask of a table field? It would be asking more if we follow the path of overlaying tinted controls. This can be done, of course.

craig

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”