Discussions related to Visual Prolog
Posts: 12
Joined: 16 Nov 2012 1:50

Edit Control Insert Text, Clear Text, Get Text

Unread post by PYB »

Hi there,

Right now I am using this code to insert and clear text in an Edit Control

To insert I use

Code: Select all

Msg = string::format("% \n %", edit1_ctl:getText(), "Some text"), edit1_ctl:setText(Msg).
and to clear just

Code: Select all

which is the right way to do this ?

I checked in the class and there should be an insert/add text and clear text functionality.

Thank you, bye.
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Unread post by Ferenc Nagy »

You have solved the clearing of the text correctly.
The insertion needs an insertion point.

The insertion needs a selection within the edited text.
You can set it by

Code: Select all

selectText : (charCount First, charCount Last).
and get it using

Code: Select all

getTextSelection : (charCount First [out], charCount Last [out]).
You can split the whole contents by the edit control

Code: Select all

edit_ctl:getText()=WholeText, edit_ctl:getTextSelection(First,Last), string::splitLength(WholeText,[First,Last-First,string:length(WholeText)-Last)=[Front,_Throwaway,Tail], edit_ctl:setText(string::concat(Front,Inserted,Tail)).
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1245
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

You could also consider using a messageControl instead.
Regards Thomas Linder Puls
Post Reply