Lazarus

Installation => Windows (32/64) => Topic started by: maaah on June 13, 2010, 10:18:12 pm

Title: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: maaah on June 13, 2010, 10:18:12 pm
Title says all I mean. Here is a screen video:

http://www.viamep.com/share/lazarus-bug-editor-seltext-cursor-goes-top.wmv

(11 MB, 4 min, 1680x1050)

I'm using Memo. If I have this:

memo1.seltext := 'something...' + memo1.seltext + 'hello world';

Cursor goes to top. I think there is a bug in win32/64 Lazarus implementation of system Memo.
Title: Re: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: Mr.Paul on March 26, 2013, 05:20:04 pm
I met the Similar problem , on  two years later.   The environment is: Lazarus 1.0.8 on Windows XP.

When more strings words within the memo, that is, the vertical scroll bar appears, then executed:
Code: [Select]
    Memo1.SelText: = 'some + words';      // it works + but ...
Scroll bar will goto the top !?
Puzzling is the insertion point cursor, still on position of seltext.
Title: Re: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: howardpc on March 26, 2013, 05:51:12 pm
A simple workaround for situations you know will move the cursor where you don't want it to go, is to save the value of CaretPos before the code in question, and restore it (immediately after that code executes) to its original value.
Title: Re: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: Mr.Paul on March 26, 2013, 06:07:53 pm
Thanks for reply, but I did not succeed:
Code: [Select]
var old:Tpoint;
begin
  old:=memo1.CaretPos;
  Memo1.SelText: = 'some + words';
  Memo1.caretPos:=old;
end;
It should be noted, CaretPos always been correct.
Incorrect position of the scrollbar, memo shows the location of the text is.
Title: Re: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: u2o on April 07, 2013, 03:00:33 am
Hi! Try

Code: [Select]
var
  old: Integer;
begin
  old := Memo1.SelStart  ;
  Memo1.SelText := 'some' + Memo1.SelText + 'words';
  Memo1.SelStart := old;
  Memo1.SetFocus ;
end;

The scrollbar is moved to the selected line...
Title: Re: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: fedkad on September 03, 2016, 06:19:32 pm
I have met the same problem. However, the workaround posted by u2o is not a perfect solution, because scrollbar still moves up, but as much as possible, so that the SelStart point is displayed at the bottom of the memo.

Detailed explanation:
On a long memo with vertical scroll bar and which has more data that can fit on its viewable area, when the vertical scroll bar is at the top and you make something like Memo.SelText := 'blabla'; there is no problem. If you make a change when to scroll bar is not at the top, the scroll bar moves to the top regardless of the position of the SelStart point, which in some cases moves out of the scope.

If you use a workaround like Memo.SelStart := Memo.SelStart; the scrollbar still tries to move to the top, but this movement is as much as the selection point stays in view, but at the bottom (last line) of the viewable area of the memo.

Normally no movement should occur, as in Delphi.
Title: Re: Bug: If I Modify memo.seltext cursor goes to top... Why?
Post by: fedkad on September 06, 2016, 01:09:08 pm
http://forum.lazarus.freepascal.org/index.php/topic,33919.0.html
TinyPortal © 2005-2018