Page 1 of 2

Table Field

Posted: Fri Mar 27, 2020 5:49 pm
by wanglucas
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...

Re: Table Field

Posted: Fri Mar 27, 2020 6:03 pm
by FourthWorld
"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?

Re: Table Field

Posted: Fri Mar 27, 2020 6:17 pm
by wanglucas
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

Re: Table Field

Posted: Fri Mar 27, 2020 6:43 pm
by wanglucas
also @fourthworld

i noticed in your signature you offer training services?

Re: Table Field

Posted: Fri Mar 27, 2020 7:26 pm
by FourthWorld
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

Re: Table Field

Posted: Fri Mar 27, 2020 7:35 pm
by wanglucas
just emailed you

Re: Table Field

Posted: Fri Mar 27, 2020 9:09 pm
by wanglucas
related to this same table

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

Re: Table Field

Posted: Fri Mar 27, 2020 9:27 pm
by Klaus

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

Re: Table Field

Posted: Fri Mar 27, 2020 9:42 pm
by wanglucas
what if i just want change the contents of a label itself
label.png

Re: Table Field

Posted: Fri Mar 27, 2020 9:51 pm
by Klaus
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.

Re: Table Field

Posted: Fri Mar 27, 2020 9:57 pm
by richmond62
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

Re: Table Field

Posted: Sat Mar 28, 2020 5:20 pm
by richmond62
Just too hard to resist: :shock:
-
Tabler2.png
-

Re: Table Field

Posted: Mon Mar 30, 2020 10:37 am
by richmond62
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?

Re: Table Field

Posted: Mon Mar 30, 2020 11:15 am
by bogs
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

Re: Table Field

Posted: Mon Mar 30, 2020 11:36 am
by richmond62
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