Table Field

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

wanglucas
Posts: 31
Joined: Thu Mar 19, 2020 2:25 am

Table Field

Post by wanglucas » Fri Mar 27, 2020 5:49 pm

Hello All

Im trying to find some info on how to edit the size of a table field (for example an 8X8)

and then also be able to do this problematically

Ive looked around on google and within the search bar on the forums/live code website

so if anyone could point me to the documentation it would be appreciated

note has to be a table field and not data grid...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Table Field

Post by FourthWorld » Fri Mar 27, 2020 6:03 pm

"8x8" what? Probably not pixels. Do you mean "cells"?

The size and location of any object in LiveCode is determined by its rectangle property.

Column widths are determined the field's tabWidth property.

The height of a line of text in a field is determined by the field's textHeight property.

Does that help?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

wanglucas
Posts: 31
Joined: Thu Mar 19, 2020 2:25 am

Re: Table Field

Post by wanglucas » Fri Mar 27, 2020 6:17 pm

it does help, thank you



i was able to do this with the property inspector(editing the tab stops and font size) but i was wondering how would you do this programmatically
table.png

wanglucas
Posts: 31
Joined: Thu Mar 19, 2020 2:25 am

Re: Table Field

Post by wanglucas » Fri Mar 27, 2020 6:43 pm

also @fourthworld

i noticed in your signature you offer training services?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Table Field

Post by FourthWorld » Fri Mar 27, 2020 7:26 pm

wanglucas wrote:
Fri Mar 27, 2020 6:17 pm
i was able to do this with the property inspector(editing the tab stops and font size) but i was wondering how would you do this programmatically
Property syntax in LC is fairly consistent across properties and objects, e.g.:

Code: Select all

set the rect of fld 1 to 20,20,600,600
set the tabStops of fld 1 to 200
...etc.

The exact values you'd use will of course depend on the specifics of your layout. For an understanding of those properties, see the Dictionary entries for each.
i noticed in your signature you offer training services?
I do, and have been since before LiveCode 1.0. Feel free to drop me an email to discuss what you'd like help with: ambassador AT fourthworld DOT com
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

wanglucas
Posts: 31
Joined: Thu Mar 19, 2020 2:25 am

Re: Table Field

Post by wanglucas » Fri Mar 27, 2020 7:35 pm

just emailed you

wanglucas
Posts: 31
Joined: Thu Mar 19, 2020 2:25 am

Re: Table Field

Post by wanglucas » Fri Mar 27, 2020 9:09 pm

related to this same table

how would one change the contents of a Label without using the Property Inspector only Progamatically

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

Re: Table Field

Post by Klaus » Fri Mar 27, 2020 9:27 pm

Code: Select all

set the label of btn "xyz" to "I'm a label!"
8)

I can recommend these stacks to learn the very basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html

wanglucas
Posts: 31
Joined: Thu Mar 19, 2020 2:25 am

Re: Table Field

Post by wanglucas » Fri Mar 27, 2020 9:42 pm

what if i just want change the contents of a label itself
label.png

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

Re: Table Field

Post by Klaus » Fri Mar 27, 2020 9:51 pm

Is this a TABLE field in the screenshot?

A TABLE FIELD is basically just a scrolling text field and the content is TAB and CR delimited text.
So to change the text in the first line, which is NOT a LABEL, just the string LABEL 8) ***, do like this:

Code: Select all

...
set itemdel to TAB
put "a label" into item 1 of line 1 of fld "your table field here"

## Change line 3, too:
put "No label" into item 1 of line 3 of fld "your table field here"
## etc. you get the picture...
...
*** Please get used to use the correct terms to avoid misunderstandings in the future.

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

Re: Table Field

Post by richmond62 » Fri Mar 27, 2020 9:57 pm

Those aren't labels; they are just the first item in each row of a table field.
-
Tabler.png
-

Code: Select all

on mouseUp
   put 1 into KOUNT
   repeat until KOUNT > 12
      put ("Line" && KOUNT) into item 1 of line KOUNT of fld "tf"
      add 1 to KOUNT
   end repeat
end mouseUp
Attachments
Tabler.livecode.zip
Here's the stack.
(1.07 KiB) Downloaded 168 times

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

Re: Table Field

Post by richmond62 » Sat Mar 28, 2020 5:20 pm

Just too hard to resist: :shock:
-
Tabler2.png
-
Attachments
Tabler.livecode.zip
Here's the stack.
(1.26 KiB) Downloaded 180 times

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

Re: Table Field

Post by richmond62 » Mon Mar 30, 2020 10:37 am

This doesn't work:

Code: Select all

set the backGroundColor of item 1 of line 1 of fld "tf" to red
as it sets the backGroundColor of the whole tableField to red.

I wonder if there is a way to set individual "cells" to a colour?

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

Re: Table Field

Post by bogs » Mon Mar 30, 2020 11:15 am

Did you try changing the itemDelimter to tab?
aPic_itemColor.png
One a color, two a color...

Code: Select all

# in the button script...
on mouseUp
      put "" into field 1
   set the itemDelimiter to tab
   repeat with x=1 to 20
      put any line of the colorNames into item random(20) of line random(20) of field 1
   end repeat
   
   repeat with x=1 to the number of words in field 1
      put word x of field 1 into tmpVar 
      set the backGroundColor of word x of field 1 to tmpVar
   end repeat
   
end mouseUp
You can do all kinds of neat stuff in just 15 minutes (or less) :P
Image

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

Re: Table Field

Post by richmond62 » Mon Mar 30, 2020 11:36 am

Did you try changing the itemDelimter to tab?
Yes.

Code: Select all

on mouseUp
   put empty into fld "tf"
   set the itemDelimiter to TAB
   ------
   set the backGroundColor of item 1 of line 1 of fld "tf" to red
   put "be" into item 2 of line 2 of fld "tf"
   put "completely" into item 3 of line 3 of fld "tf"
   put "bonkers" into item 4 of line 4 of fld "tf"
   put "!!!!!!!!!!" into item 5 of line 5 of fld "tf"
end mouseUp
-
Screenshot 2020-03-30 at 13.36.26.png

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”