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.
T = CTextView:new( sTitle=nil, CRect=nil )
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.
The following script fragment creates a new CTextView and opens a Mira Text Editor window with the specified title:
|
-- create a new instance T of the CTextView class. |
|
-- other uses of the class go here |
|
-- deletes the object. |
The next example creates a new CTextView with a specified title and size
|
-- window title |
|
-- window rectangle relative to main window |
|
-- create a new instance T with title and size |
|
-- no longer need the CRect |
|
-- other uses of the class go here |
|
-- deletes the object. |