IDLgrTextEdit::Insert

The IDLgrTextEdit::Insert procedure method inserts text at the current cursor position. If text is selected, it overwrites the selected text and sets the selection length to zero. (See the SELECTION_LENGTH property of the IDLgrText object for more information.)

Syntax

Obj->[IDLgrTextEdit::]Insert, Text

Arguments

Text

A string containing the text to be inserted.

Keywords

None

Examples

Example 1

oWindow = OBJ_NEW('IDLgrWindow', RETAIN=2)
oView = Obj_new('idlgrview')
oModel = OBJ_NEW('IDLgrModel')
oView->Add, oModel
oText = obj_new('idlgrtextedit', 'This is a string', $
   FONT=oFont, LOCATIONS=[-0.9,0])
oModel->Add, oText
oWindow->Draw, oView
oText->SetProperty, SELECTION_START=10, /DRAW_CURSOR
oWindow->Draw, oView

To add another string at this position, use:

oText->Insert, 'longer '
oWindow->Draw, oView

Which results in the following sting:

Destroy the IDLgrWindow and IDLgrView objects before we proceed:

OBJ_DESTROY, [oWindow, oView, oFont]

Example 2

The next example shows selected text in a string that will be replaced using INSERT:

oWindow = OBJ_NEW('IDLgrWindow')
oView = Obj_new('idlgrview')
oModel = OBJ_NEW('IDLgrModel')
oView->Add, oModel
oText = obj_new('idlgrtextedit', 'A cute dog', $
   FONT=oFont, LOCATIONS=[-0.9,0])
oModel->Add, oText
oText->SetProperty, SELECTION_START=2, SELECTION_LENGTH=4, $
   /DRAW_CURSOR
oWindow->Draw, oView

To replace the selected string with the word “brown,” use:

oText->Insert, 'brown'
oWindow->Draw, oView

Which results in the following string:

Destroy the IDLgrWindow and IDLgrView objects.

OBJ_DESTROY, [oWindow, oView, oFont]

Version History

7.0.6

Introduced