Table Field Cells

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

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10097
Joined: Fri Feb 19, 2010 10:17 am

Table Field Cells

Post by richmond62 » Thu Dec 16, 2021 2:13 pm

1. I would like to FILL a particular cell of a table field red:

pseudocode:

set the backColor of cell 2,3 of field "tf" to red


and should like to know how this can be done.

2. I should like to set the height and width of cells in a table field (a bit like the way one can do that in a spread sheet).

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

Re: Table Field Cells

Post by richmond62 » Thu Dec 16, 2021 2:19 pm

Screen Shot 2021-12-16 at 3.15.34 PM.png
-
Really?

The dictionary is no further help.
-
Screen Shot 2021-12-16 at 3.18.37 PM.png

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

Re: Table Field Cells

Post by richmond62 » Thu Dec 16, 2021 2:21 pm

Screen Shot 2021-12-16 at 3.20.17 PM.png
-
Erm . . . columns, cells?
-
Please do NOT respond with anything to do with "Data Grids".

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Table Field Cells

Post by Klaus » Thu Dec 16, 2021 2:41 pm

Glossary <> keyword
Glossary <> property
etc.
So don't blame the dictionary! :D

Means we can only set the backcolor of the whole field, its lines and their ITEMS (itemdel = TAB)
in the field and this will obviously only work if there is already text in that "cell".

Code: Select all

...
set the itemdel to TAB
set the backgroundcolor of item 2 of line 4 of fld 1 to "red"
...
Does the trick but only if there is already text in that item.
and it will only "cover" background of the text not the whole ITEM.
In the end, the "table field" is just a simple text field with a script library.
If you want more, just use a ... 8)

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

Re: Table Field Cells

Post by dunbarx » Thu Dec 16, 2021 2:47 pm

Richmond.

All that Klaus said.

A table field is just a field, a single lone field, that has certain properties set to make it look and feel like it does. You can make one from a standard field if you take the time to do so. Anyway, that means that, unlike a dataGrid, which is a group of separate fields, each named by virtue of its place in the "grid", you cannot do what you wanted to.

Craig

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

Re: Table Field Cells

Post by dunbarx » Thu Dec 16, 2021 3:54 pm

Richmond.

You can kludge this if you really are interested. A table field generates messages, for example, "mouseUp". Know that one of the gadgets of a table field is the creation of a "phantom" field that you can exploit. Try this in a new table field on a new card. Fill the table field with some simple text. These will be tab and return delimited, as I am sure you know. Now in the field script"

Code: Select all

on mouseUp
 answer the name of last field & return & the rect of the last field
end mouseUp
This is data for the phantom field. You can use this to perhaps create your own new colored field that can size itself and overlie where the phantom field was. just manage all those new fields and you are done. The phantom field, when generated, will always be the last field, regardless of all your shenanigans. :wink:

Craig
Last edited by dunbarx on Thu Dec 16, 2021 4:17 pm, edited 1 time in total.

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

Re: Table Field Cells

Post by dunbarx » Thu Dec 16, 2021 3:58 pm

Richmond.

Played around just for a minute. In that table field script;

Code: Select all

on mouseUp
   put the rect of the last field into tRect
   create field
   set the rect of last field to tRect
   set the backColor of last field to "yellow"
   set the blendLevel of last field to 50
end mouseUp
So we now know that the "last" field changes rather quickly, eh? From phantom to the one you created.

Craig

Post Reply