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. Note that this object can also be created using the new_textview function.

Syntax

T = CTextView:new( sTitle=nil, CRect=nil )

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

bullet.gif    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.

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

bullet.gif    On failure, nil is returned.

Remarks

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, 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.

Example

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

strTitle = "My Window Title"

-- window title

R = new_rect(0.1,0.7,0.1,0.7 )

-- window rectangle relative to main window

T = CTextView:new(strTitle, 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

CTextView, delete


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.