CTextView:new


The new method creates an instance of the CTextView class. A new Mira Text Editor window is opened with the specified title, unless a Text Editor already exists with the same name.

Syntax

T = CTextView:new()

T = CTextView:new( sTitle )

T = CTextView:new( sTitle, CRect )

where

    sTitle is a string that specifies the window caption. if nil, a default is used.

    CRect is a rectangle specifying the fractional dimensions of the window in terms of the Mira viewport. All CRect members must be between 0 and 1. If not specified or if nil, then a default window size is used.

    On success, a text window is created and a non nil CTextView object is returned.

    On failure, nil is returned.

  

The CTextView constructor attaches itself to a Mira Text Editor window based on the specified name. If a Text Editor window of the same name already exists, this constructor attaches to that window. Otherwise, a new window is created.

Note that the CRect argument specifies a window size in terms of the current Mira viewport (the main window size). For example, if CRect contains the dimensions (0.1, 0.7, 0.1, 0.7), then a window will be created that extends from 10% to 70% of the viewport size.

This method returns to the caller a reference to the object it creates. The calling code must assign this reference to a name (see below), as in T = CTextView:new("My Window Title"). If the object cannot be created, nil is returned for T.

This method's name uses all lower case to present it as the analog of the C++ new operator. Generally, the names of class methods begin with an uppercase letter but new and delete are different.

Examples

The following script creates a new CTextView and opens a Mira Text Editor window with the specified title:

T = CTextView:new("Title")

-- create a new instance T of the CTextView class.

  --

-- other uses of the class go here

T:delete()

-- deletes the object.

The next example creates a new CTextView with a specified title and size

sTitle = "My Window Title"

-- window title

R = NewRect(0.1,0.7,0.1,0.7 )

-- window rectangle relative to main window

T = CTextView:new(sTitle, R)

-- create a new instance T with title and size

R:delete()

-- no longer need the CRect

  --

-- other uses of the class go here

T:delete()

-- deletes the object.

Related Topics

delete

CTextView class