is it possible to have styled text in a field?

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
jpottsx1
Posts: 46
Joined: Thu Jun 04, 2009 12:46 am
Contact:

is it possible to have styled text in a field?

Post by jpottsx1 » Fri Feb 19, 2010 2:26 pm

I've looked at the lessons and tutorials but cannot find out any way of putting styled text into a field from within Runrev. I don't see any formatting opotions such as bold or text size.

Any ideas? Can it be done? Can something like tText be used for this purpose?
Jeff G potts

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: is it possible to have styled text in a field?

Post by BvG » Fri Feb 19, 2010 2:47 pm

No idea what "tText" is, but there's basically two ways to change the styling of a text wit code.

If you'd have bothered to look into the dictionary for bold, italic or unerline, you'd have found the textstyle property. That property allows for various other styles too. For size and font choices you can see the textfont, and the textsize. You can set parts of a fields text to have various styles. All these properties can also be set on a field or any object higher up in the message path, and are then inherited downwards. So if you set the textstyle of your stack to bold, all text in that stack (that has no individual styles set) will be bold.

Sometimes the styles properties are not powerfull enough, at which point it's neccessary to use the htmltext. The advantage is, that you can create htmltext in a variable, and only then set the htmltext of a field to that. You can't do that with the style properties, as variables do not have properties. Note that htmltext is not html 4.0. It's just similar to html, but rev's own specific implementation that is only similar to the standard html. So make sure to look it up in the dictionary.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

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

Re: is it possible to have styled text in a field?

Post by bn » Fri Feb 19, 2010 2:57 pm

Jeff,
you can set a lot of text properties by script. Like

Code: Select all

 set the textcolor of word 2 of field 1 to red
or

Code: Select all

set the textstyle of word 2 of field 1 to bold
What you do then is that you change the htmlText of the field. A field has a text property which is the plain ascii text and a htmlText property. Look up htmlText in the dictionary.
If you want to see the htmlText property you can do this:
make a simple stack with 2 fields. You put just some words into field 1. Than you set the textcolor and textstyle with obove scripts. Make a button with

Code: Select all

on mouseUp
   put the htmlText of field 1 into field 2
end mouseUp
as it's script. In field 2 you will see some html, which represents the htmlText of your field 1.
In the help menu choose Resource Center. There are some tutorials
e.g.
-> revolution coding -> Text
-> tutorials -> sample scripts -> text-> replacing a text style in a field
I hope this gets you started on this, don't hesitate to ask. It can get rather involved, depending on what you want. It can also be easy if you just want to change some aspects of your text.
regards
Bernd

Post Reply