TWebMemo small issue

I want to display a static text with twebmemo readonly. The component always displays the text plus one empty line. This is ok if the user wants to append any text. But not if the webmemo is readonly. A not needed scrollbar appears if the number of lines matches exactly.

Peter

I tested this here with:

procedure TForm2.WebButton1Click(Sender: TObject);
begin
  webmemo1.ReadOnly := true;
  webmemo1.Lines.Text := 'One line';
end;

but I could not see an extra empty line added?

Please try following 2 examples:

1.)
procedure TForm1.WebButton3Click(Sender: TObject);
begin
webmemo1.readonly := true;
webmemo1.clear;
webmemo1.lines.add('line 1');
webmemo1.lines.add('line 2');
webmemo1.lines.add('line 3');
end;

The result is:
image

Why is there a vertical scrollbar ?

2.)
procedure TForm1.WebButton3Click(Sender: TObject);
begin
webmemo1.readonly := false;
webmemo1.clear;
webmemo1.lines.add('line 1');
webmemo1.lines.add('line 2');
webmemo1.lines.add('line 3');
end;

The result is the same:
image

Now webmemo is editable and place the Cursor at the end of the text and press Backspace. Then the scrollbar disappears as you can see here:
image

Peter

It is a rendering behavior of the browser we cannot do anything about it. There is NO extra line added in the memo by our code.

You can verify this in the following way retrieving via JavaScript the effective text in the HTML TEXTAREA element for the memo with:

var
el: TJSHTMLElement;
s: string;
begin
el := webmemo1.ElementHandle;
asm
s = el.value;
console.log(s);
end;
end;

In the console, you can clearly see the lines added WITHOUT extra line.

You are right.

New issue with memos:

create following:

image

type
TForm1 = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
procedure FormResize(Sender: TObject);
end;
var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormResize(Sender: TObject);
begin
panel1.Caption:=inttostr(memo1.Lines.Count);
end;

Now insert any text into the memo with long lines and resize the window.
Now the memo must recalculate the number of lines because wordwrap=true.

In windows this works correct. In the browser it does not count the real
number of lines.

Do you see any chance to get that working ?

Peter

The wordwrap is happening automatically at a underlying HTML TEXTAREA element.
I could not see a possibility at JavaScript level to detect where the HTML TEXTAREA element performed the word-wrap.