news
About Elegant Chaos
info
About me and my friends
people
Software from Elegant Chaos
software
Other stuff...
stuff

TextView

An XCMD which creates an external window containing some styled text .

TextView XCMD. Version 3.1d17, by Sam Deane. Copyright 1994 ULTRALAB. Compiled 15:44:20, 12/12/94. Debugging code included.


[last exit to hypercard] [externals index] [download TextView]

Description

The TextView command allows you to create external windows which display the contents of a text field.

The text can be taken from a text field, a TEXT/styl resource pair or passed directly to the XCMD as a parameter.

The window can be of any style, floating or not, with or without scrollbars. The justification can be left,center or right, with or without line wrapping. The text can be editable, or locked. If locked, clicking on it can cause a word, or line to be hilighted, and a message can be sent to hypercard to be acted on.


Commands

text

The syntax of the command is:

  TextView "text",<text>,<window> {,<floating> {,<wdef> }}

The <text> parameter specifies the initial contents of the window.

The <window> parameter indicates the name of the window to create.The optional <floating> and <wdef> parameters indicate what kind of window the text is to be displayed in.

The <floating> parameter is boolean. If true the window will always float above the card(this is the default), if false the window will behave just like another card windw.

The <wdef> parameter can be used to specify the name or id of a custom WDEF function to use for the window. It can be in one of the following forms:

    "<name>"
    "<id>"
    "<name>,<variation>"
    "<id>,<variation>"

In the two-item form, the <options> item is the WDEF variation code, which should be anumber between 0 and 15 (see the Window Manager chapters of Inside Macintosh for further explanation of WDEFs and variation codes).

card

The syntax of the command is:

  TextView "card",<name>,<window> {,<floating> {,<wdef> }}

The <name> parameter indicates the name of the card field to look in for the contents of the window.

The <window> parameter indicates the name of the window to create.The optional <floating> and <wdef> parameters indicate what kind of window the text is to be displayed in.

The <floating> parameter is boolean. If true the window will always float above the card(this is the default), if false the window will behave just like another card windw.

The <wdef> parameter can be used to specify the name or id of a custom WDEF function to use for the window. It can be in one of the following forms:

    "<name>"
    "<id>"
    "<name>,<variation>"
    "<id>,<variation>"

In the two-item form, the <options> item is the WDEF variation code, which should be anumber between 0 and 15 (see the Window Manager chapters of Inside Macintosh for further explanation of WDEFs and variation codes).

background

The syntax of the command is:

  TextView "background",<name>,<window> {,<floating> {,<wdef> }}

The <name> parameter indicates the name of the background field to look in for the contents of the window.

The <window> parameter indicates the name of the window to create.The optional <floating> and <wdef> parameters indicate what kind of window the text is to be displayed in.

The <floating> parameter is boolean. If true the window will always float above the card(this is the default), if false the window will behave just like another card windw.

The <wdef> parameter can be used to specify the name or id of a custom WDEF function to use for the window. It can be in one of the following forms:

    "<name>"
    "<id>"
    "<name>,<variation>"
    "<id>,<variation>"

In the two-item form, the <options> item is the WDEF variation code, which should be anumber between 0 and 15 (see the Window Manager chapters of Inside Macintosh for further explanation of WDEFs and variation codes).


Properties

editable

If this property is true, the text in the window will be editable.

This means that you can type, cut, copy paste etc in the window.

You can also use the font and style menus to change the appearance of text in the window.

text

This property allows you to get/set the contents of the window.

selChunk

The selChunk property returns the start and end characters of the current selection in the window.

dontWrap

If this property is true, the text in the window will not wrap if it is too wide to fit in to one line.

textAlign

This property allows you to choose whether the text in the window should be left justified, right justified or centered.

Example script for textAlign

on mouseUp
  if GotTest() then
    ask "Align?" with the textAlign of window "test"
    if it is not empty then
      set the textAlign of window "test" to it
    end if
  end if
end mouseUp

margin

This property allows you to get/set the size of the margin around the text in a window.

wholeLine

This property determines what happens when the user clicks on some non-editable text (the editable property is set to false).

If the wholeLine property is true, clicking on some text will hilight the whole line.

If the wholeLine property is false, clicking will just hilight the word that was clicked.

scrollbar

This property allows you to choose the width of the scrollbar.

You can set the scrollbar width to any number, or to the constant default which will set it to the standard width.

clickMessage

If the text window is locked, a message is sent to the card whenever the user clicks on the window.

The clickMessage property allows you to set the message that is sent.

closeOnHide

If this property is true, when the user clicks on the window's close box, it will be permanently closed.

If the property is false, clicking on the close box will simply hide the window.

properties

rect

This property allows you to get/set the rectangle of the window.

globalRect

This property allows you to get/set the rectangle of the window, in global coordinates.

gotGrow

If the gotGrow property is true, the window will be shown with a close box.

selText

selLine

This property allows you to find out which line is currently selected in the window.

By setting the property, you can use it to select a line.

foreground

This property allows you to get/set the foreground colour of the text in the window.

The colour is specified as three numbers: <red>,<green>,<blue>.

The larger the number, the higher the amount of that colour - so "0,0,0" represents black, and "65535,65535,65535" white.

Example script for foreground

on mouseUp
  if GotTest() then
    ask "Foreground?" with the foreground of window "Test"
    if it is not empty then
      set the foreground of window "Test" to it
    end if
  end if
end mouseUp

background

This property allows you to get/set the background colour of the window.

Example script for background

on mouseUp
  if GotTest() then
    ask "Background?" with the background of window "Test"
    if it is not empty then
      set the background of window "Test" to it
    end if
  end if
end mouseUp

executable

Example script for executable

on mouseUp
  if GotTest() then
    set the editable of window test to true
    set the executable of window test to true
    show window test
  end if
end mouseUp

font

This property allows you to set the font of the current text selection.

Example script for font

on mouseUp
  if GotTest() then
    show window test
    ask "Font?"
    set the editable of window test to true
    set the selChunk of window test to "0,32000"
    set the font of window test to it
  end if
end mouseUp

size

This property allows you to set the size of the current text selection.

Example script for size

on mouseUp
  if GotTest() then
    show window test
    ask "Size?"
    set the editable of window test to true
    set the selChunk of window test to "0,32000"
    set the size of window test to it
  end if
end mouseUp

style

This property allows you to set the style of the current text selection.

hideMessage

moveMessage

hiddenText

returnMessage

idleMessage

lines

gotClose

chars

autoView

gotFocus

locked

dragable

#L #@ p


Messages

import

This command allows you to import the contents of a text field into a TextView window. The syntax is:

  send "import <field>,<card>" to window <name>

The <field> parameter should contain the name of the field which the text is to be import from. The <card> parameter should be true if the field is a card field, false otherwise.

The text in the field will completely replace any old text in the window.

Example script for import

on mouseUp
  if there is a window test then
    send "import test,true" to window "Test"
  end if
end mouseUp

export

The export command allows you to export the contents of a window into a text field.

The syntax is:

  send "export <field>,<card>" to window <name>

The <field> parameter should contain the name of the field to which the text is to be exported. The <card> parameter should be true if the field is a card field, false otherwise.

insert

This command allows you to insert the contents of a text field into a TextView window.

The syntax is:

  send "insert <field>,<card>" to window <name>

The <field> parameter should contain the name of the field which the text is to be import from. The <card> parameter should be true if the field is a card field, false otherwise.

The text in the field will be inserted into the text window at the current selection point.

getFocus


[last exit to hypercard] [externals index] [download TextView]

This page was created automatically, on 25/03/1999 from version 3.0d4 of Last Exit To Hypercard.