Jump to content

How to add text to UnimMemo without linefeeds


likemike

Recommended Posts

Hello!

If I try to add a string to UnimMemo, 2 linefeeds are added:

UnimMemo1.Text:='Hello!';
UnimMemo1.Text:=UnimMemo1.Text+'Test';

The result is:

Quote

Hello!
Test
<cursor is here>

So I tried this solution:

But this doesn't work with UnimMemo (Ajax error: undefined is not an object (evaluating 'Ext.form.field.TextArea.prototype') )

Link to comment
Share on other sites

8 hours ago, likemike said:

But this doesn't work with UnimMemo (Ajax error: undefined is not an object (evaluating 'Ext.form.field.TextArea.prototype') )

You can try this modified code for the mobile version.

Ext.form.TextArea.prototype.insertAtCursor = function(txt) {
    var val = this.getValue(),
        start = this.inputElement.dom.selectionStart,
        end = this.inputElement.dom.selectionEnd;

    this.setValue(val.substring(0, start) + txt + val.substring(end));
    this.inputElement.dom.selectionStart = this.inputElement.dom.selectionEnd = start + txt.length;
    Ext.defer(function() {
        this.focus(false);
    }, 10);
}

 

Link to comment
Share on other sites

19 minutes ago, likemike said:

But why is it necessary to do such (normally) easy things so complicated?

 

5 hours ago, Sherzod said:
Ext.form.TextArea.prototype.insertAtCursor = function(txt) {
    var val = this.getValue(),
        start = this.inputElement.dom.selectionStart,
        end = this.inputElement.dom.selectionEnd;

    this.setValue(val.substring(0, start) + txt + val.substring(end));
    this.inputElement.dom.selectionStart = this.inputElement.dom.selectionEnd = start + txt.length;
    Ext.defer(function() {
        this.focus(false);
    }, 10);
}

Well, actually this is for a another case.

 

This solution is suitable for your case:

13 hours ago, likemike said:
UnimMemo1.Text:='Hello!';
UnimMemo1.Text:=UnimMemo1.Text+'Test';
  UnimMemo1.Text := 'Hello!';
  UnimMemo1.Text := TrimRight(UnimMemo1.Text) + 'Test';

 

Link to comment
Share on other sites

×
×
  • Create New...