Need to make Grids with colors??

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

no1g8tor96
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 46
Joined: Fri Aug 02, 2013 12:14 am

Need to make Grids with colors??

Post by no1g8tor96 » Thu Mar 11, 2021 12:27 am

I need to made grids that fill in with colors. and data, not from a database. Each square needs to be able to be a different color. I have been using table a table field but it wont fill in a whole square. I was thinking outside the box and put the spaces in and set the background color but looks bad.

ALSO.... as the table field fills down to the bottom....is there a way to have it automatically scroll up cause its a pain to keep scrolling up to see the new data populating on the bottom rows?

Thanks in advance.

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

Re: Need to make Grids with colors??

Post by dunbarx » Thu Mar 11, 2021 2:55 am

Hi.

It is possible to kludge almost anything in LiveCode, but a table field is really just an ordinary field with certain properties. The point is that each "cell" in a table field is not its own control. It is just a "space" defined and delimited by tabs and returns. That means it is not easy or straightforward to set the backColor of any particular "area".

A dataGrid is built from separate fields, and you can set the backColor of any one of them directly. But dataGrdis are complex, and require their own learning curve. But if you do not need a lot of functionality, using it mainly as something simply to display and hold information similar to a spreadsheet, it might be the best way forward.

How big is your "table"? If it is not too large, and does not change, you might assemble several fields together in a group.

Lots of possibilities. So tell me more about your project. There will be a way to do what you want.

Know that you can set the scroll of a tableField to zero any time you want, certainly after any action is taken or data changed. Do you know how to do this?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9251
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need to make Grids with colors??

Post by richmond62 » Thu Mar 11, 2021 10:51 am

Blast: naive Richmond tried this:

Uncode:

Code: Select all

on mouseUp
  set the backGroundColor of cell 2,2 to red of fld "MENSA"
end mouseUp
and this:

Code: Select all

on mouseUp
  set the backGroundColor of cell 2,2 of fld "MENSA" to red
end mouseUp
Having looked up cell in the Dictionary . . .

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

Re: Need to make Grids with colors??

Post by bogs » Thu Mar 11, 2021 12:00 pm

no1g8tor96 wrote:
Thu Mar 11, 2021 12:27 am
I need to made grids that fill in with colors. and data, not from a database. (1.) Each square needs to be able to be a different color. I have been using table a table field but it wont fill in a whole square. (2.) I was thinking outside the box and put the spaces in and set the background color but looks bad.
I see a couple of problems, and so a few questions.

1. Does every cell need to be a completely different color over the whole table? I think even with a small dataset, your likely to run out of colors fairly quickly or start running into colors that are so close they might as well be the same color.

2. You probably weren't thinking outside the box enough. For instance, you *could* have one field in the background and color that, and lay the actual field your working on in the same space and put the data in that but have the background of the field transparent. Something like how this little gadget worked.

In other words, you put the color in the background, and the data in the foreground field. Keep in mind, you'll still have to work out what color to make the text in the foreground, if you wind up with a dark background and dark text that isn't likely to be helpful :P
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9251
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need to make Grids with colors??

Post by richmond62 » Thu Mar 11, 2021 12:17 pm

Each square needs to be able to be a different color.
Sorry to put the kibosh on your suggestion, bogs.

Silly mockup:
-
SShot 2021-03-11 at 13.15.31.png

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

Re: Need to make Grids with colors??

Post by bogs » Thu Mar 11, 2021 1:55 pm

Not sure how that puts the kibosh on anything I said heh. Nicely mocked up.
Image

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

Re: Need to make Grids with colors??

Post by dunbarx » Thu Mar 11, 2021 2:48 pm

Richmond.

"Cell" is not a native word in LC, I believe, except as an idea.

What is your colorful table made of? It looks lovely.

Craig

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

Re: Need to make Grids with colors??

Post by Klaus » Thu Mar 11, 2021 2:52 pm

Hi Craig,

"cell" IS in fact a native LC word, take a look at the dictionary, where Richmond copied this script from:

Code: Select all

on mouseUp
  set the backGroundColor of cell 2,2 of fld "MENSA" to red
end mouseUp
Tried exactly it, but got an compilation error:
button "Button": compilation error at line 2 (set: missing 'to'), char 31

Another documentation error?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9251
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need to make Grids with colors??

Post by richmond62 » Thu Mar 11, 2021 2:58 pm

I did not copy that script, I wrote it myself.

But in the light of this:
-
SShot 2021-03-11 at 15.54.44.png
-
it felt legit. 8)

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

Re: Need to make Grids with colors??

Post by Klaus » Thu Mar 11, 2021 3:08 pm

I did not copy that script, I wrote it myself.
Hm, I could have sworn, I saw it there!?

Anyway, at least the dictionary entry lets one think that one could use something like this script. :D

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

Re: Need to make Grids with colors??

Post by dunbarx » Thu Mar 11, 2021 3:13 pm

I saw the word "cell" in the dictionary, but it is not a "native" word in the sense that it is part of the language. It is a glossary entry, not a keyword.

A semantic issue.

And since it is not, I do not think it can be used as Richmond implied. I got the same error Klaus did.

So, Richmond, again, what is your very colorful table comprised of, and how would you set, say, "cell 2,2" to red?

Craig

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

Re: Need to make Grids with colors??

Post by bogs » Thu Mar 11, 2021 3:23 pm

You know, I seem to remember this topic coming up previously from Richmond, but I can't seem to find it heh. Maybe someone with a bit more time this morning will find it.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9251
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need to make Grids with colors??

Post by richmond62 » Thu Mar 11, 2021 4:17 pm

this topic coming up previously from Richmond
Well, you know the old saw: "A dog always returns to his v***t." 8)

There is also a theory that if you bang on about something long enough someone might take notice of it. :D

no1g8tor96
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 46
Joined: Fri Aug 02, 2013 12:14 am

Re: Need to make Grids with colors??

Post by no1g8tor96 » Thu Mar 11, 2021 7:13 pm

ALL...

Thanks for the replies. I dont need colors all over. I am attaching a sample of what i have now...sorry should have done it when I started. You will see my table field and scroll.

When it starts filling up past the bottom rows i need to keep scrolling after each input and its a pain. Need to figure that one out.... want to be able to see at least 3 spaces at bottom at all times....if possible.

what I did to create the filled in colors is this..put " B. " and set the backroundcolor to the one needed. Works but not pretty.

I was looking at datagrids but complicated....but if I need to learn i need to learn. Is there an easy way to learn them?

I just want to color in a box...seems like it should not be hard but might be.....The cell feature would have been nice.

I could go "outside the box" more and just make square buttons and set colors and labels but scrolling will be another issue. I need up to 80 lines of data.

This is just a simple app to track Betting on Banker or Player for baccarat and will be making one for Roulette. Its for a group of guys that do this for a living that tasked me to do this. I dont gamble but i dont judge the ones that do.. They make good money though...who knew...lol

Thanks again for any suggestions.

Screen Shot 2021-02-24 at 3.35.41 PM.jpg

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

Re: Need to make Grids with colors??

Post by dunbarx » Thu Mar 11, 2021 7:58 pm

I would just love to know how either the OP or Richmond was able to color individual "cells" in a standard table field.

Cummon, you can tell me.

Craig

Post Reply

Return to “Talking LiveCode”