TEdit SelStart behaves different (incorrectly) under linux
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
Th SelStart property of TEdit does not get updated in Linux after the Text property is updated.
If you inspect the SelStart property in the TEdit's OnChange event, when you type a character in the TEdit, the reported SelStart is not correct, it is 1 less than it should be.
Only after the OnChange event, the SelStart gets updated.
Under win32 it behaves as expected (that is just like my Delphi 3 Pro does).
Steps to reproduce:
Place a TEdit and a Memo on a Form.
In the OnChange eventhandler of the TEdit place this code:
procedure TForm1.Edit1Change(Sender: TObject);
begin
Memo1.Lines.Add(Format('Edit1.Text = "%s" Edit1.SelStart = %d',[Edit1.Text,Edit1.SelStart]));
end;
Now Run the program and in the Editbox type "123" then press backspace 3 times.
The output in Memo1 under win32 is:
Edit1.Text = "1" Edit1.SelStart = 1
Edit1.Text = "12" Edit1.SelStart = 2
Edit1.Text = "123" Edit1.SelStart = 3
Edit1.Text = "12" Edit1.SelStart = 2
Edit1.Text = "1" Edit1.SelStart = 1
Edit1.Text = "" Edit1.SelStart = 0
The output in Memo1 under linux is:
Edit1.Text = "1" Edit1.SelStart = 0 (incorrect)
Edit1.Text = "12" Edit1.SelStart = 1 (incorrect)
Edit1.Text = "123" Edit1.SelStart = 2 (incorrect)
Edit1.Text = "12" Edit1.SelStart = 2 (correct)
Edit1.Text = "1" Edit1.SelStart = 1 (correct)
Edit1.Text = "" Edit1.SelStart = 0 (correct)
(the (in)correct marks I added by hand of course)
Even more strange is this. After typing 123, calling an other procedure that checks Edit1.SelStart it reports:
"Double-check": Edit1.Text = "123" Edit1.SelStart = 3
This is in fact the correct value.
I added a sampleproject that shows the bug.
Additional information:
I use the SelStart in the TEdit's OnChange to make a nice "fastfind" textbox, that does an incremetal search on keywords and when you type the first letter it will automatically fill in the rest of the first matching keyword an it will keep the characters that you did not type yourself selected, so they will be typed over as you type ahead.
As it is now, it is not possible to implement this correctly under linux.