Formatting text in text fields?

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

Post Reply
peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Formatting text in text fields?

Post by peter.s » Tue Oct 05, 2010 12:36 pm

Hi,

A general question about formatting text in text fields.

I am using text fields on my cards to display information - the text fields are read only, not editable by the user. Currently I have simply pasted the text into the Inspector's contents field, from a Word document. It naturally inherits the formatting from Word, eg: Bold heading, plain text, etc...

When I have finished the product and the card (program) is opened on another computer, will this formatting remain? Or, do I need to specify all the formatting in my card script?

Peter

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

Re: Formatting text in text fields?

Post by Klaus » Tue Oct 05, 2010 12:55 pm

Hi Peter,

yes, the text shoud appear in the stack/standalone just like you saved the stack.

Hint:
Of course this requires that all the fonts used in the field are also available on the target machine!

Best

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Re: Formatting text in text fields?

Post by peter.s » Tue Oct 05, 2010 10:03 pm

Thanks Klaus for confirming this.

I have made a point of using Arial font for this reason.

In my card scripts, I have defined the font (Arial) and font size - is this not necessary? Or is it a good idea to keep it there?

Cheers,

Peter

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

Re: Formatting text in text fields?

Post by Klaus » Tue Oct 05, 2010 10:23 pm

Hi Peter,

if you set the textfont of your fields (or chuncks inside of it) to "Arial" that should be enough.
Setting this via scripts additionally seems to be a bit "overkill" in that case :)


Best

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Re: Formatting text in text fields?

Post by peter.s » Wed Oct 13, 2010 12:19 pm

Further from my initial question about formatting text.

I have just discovered the "Text" column in the Rev Menu bar :oops: I must be a bit blind - I recently upgraded from Rev version 1, which didn't have this Text control.

Anyway - If I am preparing text fields on my cards which are read only (not editable by the user), I presume I can format it how I like by using the Text controls in the Rev menu bar and the tex/text field will stay like that after my project is made into a standalone? Otherwise why would these controls be in the menu - right?

If this is so, I can make a link in the text of my field from the Text Menu / Link option, rather than writing it in my card script... yes? Or am I missing something?

Peter

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Formatting text in text fields?

Post by bn » Wed Oct 13, 2010 1:28 pm

Peter,
I just tried this and the link option in the "Text" menu for me just sets the textstyle of the selected part, not the actual link which is the linkText. At least I did not find a way to manually enter a linkText.

Unless someone has a better idea I am afraid you will have to do it by script. Maybe the little script that you put into a field where you already have marked the link style and which is lock helps. Put it into the field's script

Code: Select all

on mouseUp
   put the clickChunk into tClick
   if tClick is "" then exit mouseUP
    put tClick
    if the textStyle of tClick is "link" then
        put the linkText of tClick into tLinkData
        ask "what should be the linkText of " & return & return & the clickText & return & "current linkText is: " & return & tLinkData
        if it is not empty then set the linkText of tClick to it
    end if
end mouseUp
this way you can manually set the linkText, if the linkText is already set it shows you the linkText.
regards
Bernd

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Re: Formatting text in text fields?

Post by peter.s » Mon Oct 18, 2010 8:41 am

the link option in the "Text" menu for me just sets the textstyle of the selected part,
I read somewhere in a reply to one of my posts (not the quote above), that using the "link" selection in the "Text" menu will set the textStyle of the selected text to Blue, Underline. I've just had a quick read through this post and can't find that statement - never mind.

I've just been using the "link" selection in the "Text" menu to set the textStyle of some text to Link - and it does not set the textStyle of the selected text to Blue, Underline. It just sets it to Underline only.

Do I need to change the settings in my stack inspector or is it normal to manually set the colour as well?

Also - I am having trouble placing a cursor in the textfield in question (actually a few of them), to edit the text. The textfield is unlocked and when I try and place the cursor by clicking where I want it to go, the best I get is a cursor at the very beginning of the textfield. The only way to move the cursor around the field is with the keyboard's arrow keys.

Any idea of why it is doing this?

Cheers,

Peter

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

Re: Formatting text in text fields?

Post by Klaus » Mon Oct 18, 2010 12:05 pm

Hi Peter,

the default should be blue and underlined", which it is, at least here on my machine right after I start up LiveCode.

There is aproperty of a stack(Inspector -> Basic Propertries -> "Underline links") that you should check.
and you can set "the linkcolor" (see the dictionary) to set the color of your links (back) to blue or any other color that fits your needs.

To set the cursor position in a field: See "select text..." in the dictionary!

To make the cursor appear anywhere in a field field you can:
...
select before text of fld "name of you field here..."
## at the beginning of a field
...
select after text of fld 2xxx"
## at the end of the text of a field
...
select after word 3 of fld "xyz"
...
select before char 3 of word 4 of line 2 of fld "xyz"
...
etc...

Best

Klaus

P.S.
Make sure that the "traversalon"/"Focusable" of your field(s) is set to true!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Formatting text in text fields?

Post by bn » Mon Oct 18, 2010 12:40 pm

Peter,
I noticed that when the text is html text that I pasted and the textcolor of the html text is black then only the underline is black, no textColoring apparent, setting the linkColor has no effect on the underline/textcolor. If you just have plain ascii text the linkColor/textColor of the link work as expected. The html-textcolor seems to override the default settings and might explain what you see. If you want to change the behavior by script just say so. Other than that you could set the text color manually while you set the link.
As to your problems with placing the cursor in an non-locked text field: if Klaus's suggestion dont help would you mind uploading just a small example stack (ziped) that shows a field where you have the problems

regards
Bernd

Post Reply