Livecode Wiki

Specifies the text contained by a button or field or the binary data in an image.Syntax:

set the text of {<button> | <field> | <image>} to <string>


put the text of button "Popup" into menuContents
set the text of field "Display Script" to the script of the target

Use the text property to work with the contents of a field, button(keyword), or image.

Fields The text of a field is simply the contents of the field. You can also use the target keyword to obtain the contents of a field :

   the text of the target is target
   -- evaluates to true if target is a field

The text of a field is always returned in the native encoding.

      1. Buttons

The text of a button(keyword) is used as the button's menu contents. (A menu whose contents is the text of a button(keyword) is called a button menu. ) If the button's style is not set to "menu", the setting of its text property has no effect. However, the text property can be used to store data in a button(keyword), regardless of the button's style; the text is not visible to the user unless the button(keyword) is a button menu.

See the menu(keyword) entry for more information about the format of menu item entries in the menu button text.

The text of a button is always returned in the native encoding.

      1. Images

The text of an image is the binary data that makes up the image. The following formats are supported:

        1. Fully Supported Formats

Setting the text to one of these formats displays the image as expected and sets the paintCompression to the correct type automatically. The data is also preserved meaning that getting the text returns the original data unchanged.

- GIF (All platforms) - JPEG (All platforms) - PNG (All platforms) - WMF (Windows only - Windows Metafile) - EMF (Windows only - Windows Enhanced Metafile)

        1. Import Only Formats

There are also some formats that are not fully supported but can be imported. The image is converted to one of the supported formats, depending on the global paintCompression property.

- BMP (Windows bitmap) - XWD (X Windows Dump format) - XBM (X Windows Bitmap) - XPM (X Windows Pixmap) - PBM (NetPBM Portable Bitmap) - PGM (NetPBM Portable Greyscale Map) - PPM (NetPBM Portable Pixmap)

Indeed, it is odd to be calling binary data the

"text" property. The usage came about for historical reasons.

These two statements are equivalent:

   set the text of object tObjectId to tString
   put tString into object tObjectId

  • Tip:* Instead of displaying a button's text when

using the button(keyword) as a menu, you can designate a stack to be displayed as the menu contents. This type of menu is called a stack menu. If the button's (object) menuName property is not empty, the stack specified by the menuName is used as the menu contents, instead of the button's (object)text property.

See also: stack (object),button (object),menuName (property),style (property),unicodeText (property),paintCompression property (property),