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.
T = CTextView:new( sTitle=nil, CRect=nil )
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, 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 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. |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.