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

Re: Cell formatting in Table Field

Post by synto » Thu Aug 22, 2019 9:15 am

Thanks very much Craig, this is very helpfull.
Unfortunately, i cannot use a vertical calendar cause i need all the width of screen, i have lots of informations to display there.

I've found a solution using unicode char like u20dd (a circle) on a table field overlaying the calendar, it's ok on the desktop PC, but on the phone, the circles are not displayed. So another solution is necessary.
For now, I'm just going to color the text of the days.


Your script is exactly what i need to get the day clicked, do you know how I can calculate the month by getting the cell clicked (using the tabstop) ?

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

Re: Cell formatting in Table Field

Post by dunbarx » Thu Aug 22, 2019 12:37 pm

Your script is exactly what i need to get the day clicked, do you know how I can calculate the month by getting the cell clicked (using the tabstop) ?
Not sure how your calendar is constructed. Are there only a series of dates without any other information? In other words, at the end of the "January" portion of the horizontal calendar, does it just read:

"27 28 29 30 31 1 2 3"

Anyway, you can determine the item clicked on:

Code: Select all

on mouseDown
   put the clickchunk into tChunk
   set the itemDel to tab
   answer the number of items of  char 1 to (word 2 of tChunk) of fld 1
end mouseDown
which will tell you which day of the year, like 125, you have. 125 would be in April. Watch out for leap years.

Craig

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

Re: Cell formatting in Table Field

Post by synto » Thu Aug 22, 2019 12:52 pm

Nice, it's exactly what i need.
Thank you very much.

strongbow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 146
Joined: Mon Jul 31, 2006 1:39 am
Contact:

Re: Cell formatting in Table Field

Post by strongbow » Thu Mar 06, 2025 1:25 am

Time passes...

and I come to the party late. But to colorise cell 3 of row 2 of a table field, you can simply do:

set the itemDel to tab
set the backcolor of item 3 of line 2 of fld "dataset2" to red

cheers

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Cell formatting in Table Field

Post by richmond62 » Thu Mar 06, 2025 9:52 am

Time does indeed pass (often in a non-linear way), but that is really useful information: thank you.

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

Re: Cell formatting in Table Field

Post by dunbarx » Thu Mar 06, 2025 4:00 pm

Strongbow.

No, that is normal field behavior, and as mentioned, a table field is just a field.

The OP wanted to colorize the entire "cell" of the field, not just the text. That is why there was so much discussion...

Craig

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

Re: Cell formatting in Table Field

Post by dunbarx » Thu Mar 06, 2025 4:27 pm

Strongbow.

Rereading that whole thread, I recall trying to work out a possible solution using certain field properties. Again, a table field is just a field, but with certain special properties. Two of those are its "hGrid" and "vGrid" properties. It occurred to me that these identified the bounds of the enclosed "cell", even though there is no such thing as a cell. LC knows about those bounds, or it could not draw the lines, but I saw no way to exploit them.

A datagrid is far easier to manipulate in this way, since its "cells" are actual separate fields.

Anyone know if the polyGrid might be a solution?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Cell formatting in Table Field

Post by richmond62 » Fri Mar 07, 2025 10:57 am

A datagrid is far easier to manipulate in this way, since its "cells" are actual separate fields.
Up to a point.

A datagrid is a 'supergroup' of constituent cells; and while that is useful in some ways, if one considers it to be a multi-cellular beastie, and a table field as an amoeba; one should be aware that, in some ways at least, an amoeba is easier to deal with than a brontosaurus.

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

Re: Cell formatting in Table Field

Post by dunbarx » Fri Mar 07, 2025 2:47 pm

Richmond.

Yes, a DG has its own learning curve, but my point was, regarding the needs of the OP, that since each "cell" in a DG is an actual field, it can be colored in its entirety, as opposed to merely the text alone.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Cell formatting in Table Field

Post by richmond62 » Fri Mar 07, 2025 7:48 pm

and I come to the party late. But to colorise cell 3 of row 2 of a table field, you can simply do:

set the itemDel to tab
set the backcolor of item 3 of line 2 of fld "dataset2" to red
No: that does NOT work.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Cell formatting in Table Field

Post by richmond62 » Fri Mar 07, 2025 7:52 pm


richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Cell formatting in Table Field

Post by richmond62 » Fri Mar 07, 2025 8:21 pm

Of course you could fill your 'cell of choice' with spaces, set the backColor of those spaces, and then bung your data BEFORE the spaces.
-
Screenshot 2025-03-07 at 21.25.27.png
-
Mind you, it still looks fairly repulsive. 8)

Post Reply