View Issue Details

IDProjectCategoryView StatusLast Update
0007243LazarusWidgetsetpublic2016-10-10 23:39
ReporterBart BroersmaAssigned ToZeljan Rikalo 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSSuse LinuxOS Version10.0
Product Version0.9.16Product Build9215M 
Target Version1.2.0Fixed in Version0.9.31 (SVN) 
Summary0007243: TEdit SelStart behaves different (incorrectly) under linux
DescriptionTh 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 ReproducePlace 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 InformationI 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.
TagsNo tags attached.
Fixed in Revision24030,24043,24048,35982
LazTarget1.2
WidgetsetGTK 2
Attached Files

Relationships

related to 0009737 closedZeljan Rikalo Select item of a combo doesn't select ComboBox.Text 
related to 0008491 closedZeljan Rikalo TEdit.OnChange is fired if text is not changed (after pressing delete or backspace) in Linux 
related to 0016678 closedZeljan Rikalo TEdit.SelStart : bug with Gtk2 
related to 0030596 resolvedJuha Manninen error in the keyboard backspace key on linux TEdit 

Activities

2006-08-09 14:23

 

selstarbug.zip (3,692 bytes)

Bart Broersma

2007-01-13 14:50

developer   ~0010831

Last edited: 2007-01-13 14:52

Just an update. The bug is still present in the 0.9.20 Linux version.
It would be nice if someone could at least confirm this issue
(at the moment I get the impression that it's just stupid me that encouters this).
Bart

Bart Broersma

2007-09-01 11:58

developer   ~0014371

If you paste text into the edit (let the OS paste the text, don't use CopyFromClipboard), SelStart isn't updated either.
If I compile for gtk2, same thing.
Maybe this helps someone finding out where it goes wrong. I've spent several hours on it now, and I don't see it.

Bart

Bart Broersma

2008-11-05 16:56

developer   ~0023184

This bug also is present in TComboBox.
It seems that SelStart if called from OnChange reports the wrong value only if text was added to the control.
Deleting text (backspace, delete, or cut via context menu) will report the right value for SelStart.
(Tested with 0.9.26/fpc 2.2.2)

Zeljan Rikalo

2010-03-10 11:29

developer   ~0035153

Works like a charm with 0.9.29 r 23857 (gtk & gtk2)

Bart Broersma

2010-03-10 15:43

developer   ~0035180

Bug is still present (GTK2, did not test GTK).
Tested with r23919 fpc 2.4.0
Q: Can you maybe next time first ask feeback (to re-test) if you think the issue has been fixed in the mean time, not just marking it as resolved?

Vincent Snijders

2010-03-10 15:50

manager   ~0035182

Last edited: 2010-03-10 15:51

Whether to ask to re-test depends how certain you are that the issue is resolved. In this case I guess Zeljan was pretty sure it was fixed, probably because you gave good steps to reproduce the issue with your test program.

In this case, resolving it was as good as asking to retest, since retesting is what you did.

What gtk2 version do you have?

Bart Broersma

2010-03-10 15:56

developer   ~0035184

> In this case, resolving it was as good as asking to retest, since retesting is
> what you did.

OK

> What gtk2 version do you have?

bart@simenon:~/svnroot/lazarus> rpm -q gtk2
gtk2-2.8.3-4

Zeljan Rikalo

2010-03-10 18:29

developer   ~0035194

@Bart, I've tested with gtk2-2.12.8-10 and used test case mentioned here (work ok with gtk & gtk2), so we are talking about gtk2 bug probably.

Bart Broersma

2010-03-11 00:02

developer   ~0035215

Could well be possible.
Maybe the order of events changed in gtk2?
Suspend this issue for the time being?

Zeljan Rikalo

2010-03-11 15:01

developer   ~0035254

@Bart, just tested under Fedora 11 64bit and works ok too. Don't know what to do with this issue, seem that it's reproducable only with your gtk2 version.Is there any chance that you can test with some newer gtk2 version ?

Bart Broersma

2010-03-15 19:13

developer   ~0035581

Only if I buy a new computer.
My hardware is currently 10 years old, and I'm afraid a newer Linux (Suse 11) is just a little bit too much for it.
AFAIK I cannot just only upgrade GTK2.

When you are fairly sure it's "My-old-version-GTK" bug, and not a bug in our GTK2 widgetset, I'm OK with closing this issue.

Zeljan Rikalo

2010-03-15 19:29

developer   ~0035584

I've tested on few Fedora distros (3, 11 + 11_64bit, 12) and I don't want to close it just because of my testings.I'll ask somebody on irc channel to test with different gtk2 version so we'll see.If I get few positive tests I'll close this issue.
OT: Bart, try LUbuntu (Ubuntu with LXDE). It'll probably work faster than your current GNOME ;)

I get the same result as the OP in Ubuntu Lucid (gtk2 2.19.7).

José Mejuto

2010-03-15 20:32

reporter   ~0035594

Checked in 0.9.29 r23781 and the result is the wrong one:

Edit1.Text = "1" Edit1.SelStart = 0
Edit1.Text = "12" Edit1.SelStart = 1
Edit1.Text = "123" Edit1.SelStart = 2
Edit1.Text = "12" Edit1.SelStart = 2
Edit1.Text = "1" Edit1.SelStart = 1
Edit1.Text = "" Edit1.SelStart = 0

Ubuntu 9.04, GTK 2.16, running in VirtualBox.

Zeljan Rikalo

2010-03-16 10:15

developer   ~0035625

Test and close if ok.
As stated in the irc channel, bug is still present in gtk2 2.19.7.

Zeljan Rikalo

2010-03-16 19:58

developer   ~0035658

Added check for gtk2 lib version.Test and close if ok.

Bart Broersma

2010-03-16 22:19

developer   ~0035671

It's almost working correctly.

When just typing all's OK.
However if you paste text in the control, then SelStart reports wrong value.

This is the output of sample program when pasting "1", then typing "2" "3"
Text = "1" SelLength = 0 SelStart = 0
Text = "12" SelLength = 0 SelStart = 2
Text = "123" SelLength = 0 SelStart = 3

If you could fix that, I'ld be very happy indeed.

Zeljan Rikalo

2010-03-16 22:39

developer   ~0035672

@Bart, problem is in gtk2 versions. After 2.17 GtkEntry works "almost" correct, but there's still gtk bug in gtkEntry which does not update cursor_pos when sending 'changed' signal,so that's the reason for such big patch because we have to update cursor_pos inside backspace,delete ,cut-clipboard and paste-clipboard signals for gtk2 < 2.17 and cursor_pos for all gtk2 versions inside callback for 'changed' signal.
cut-clipboard and paste-clipboard signals now works ok with gtk2-2.10 and 2.16 (just tested both (paste clipboard and paste selection) @home, etrusco tested 2.19) with latest svn.
Please update to latest svn and retest.
If it does not work then I must rethink what to do with that part for gtk2-2.8.
thanks.

Bart Broersma

2010-03-29 15:06

developer   ~0036237

I'll test later and report back.

Vincent Snijders

2010-11-02 16:04

manager   ~0042622

Bart, what are the results of your testing?

Bart Broersma

2010-11-03 12:37

developer   ~0042713

Tested with r28055.
The results are still the same as in note 0035671.

Zeljan Rikalo

2010-11-03 12:50

developer   ~0042715

@Bart, it'll be hard to fix - maybe even impossible for 2.8 since there are missing events which can handle such situations.

Zeljan Rikalo

2012-02-04 12:07

developer   ~0056340

Not blocker, postponing - problem exists only with gtk2 < 2.10

Zeljan Rikalo

2012-03-14 18:01

developer   ~0057646

Please test and close if ok.

Issue History

Date Modified Username Field Change
2006-08-09 14:23 Bart Broersma New Issue
2006-08-09 14:23 Bart Broersma File Added: selstarbug.zip
2006-08-09 14:23 Bart Broersma Widgetset => GTK
2006-08-17 21:53 Vincent Snijders Target => 1.0
2006-08-17 21:53 Vincent Snijders Status new => acknowledged
2007-01-13 14:50 Bart Broersma Note Added: 0010831
2007-01-13 14:52 Bart Broersma Note Edited: 0010831
2007-03-09 20:43 Vincent Snijders Relationship added related to 0008491
2007-09-01 11:58 Bart Broersma Note Added: 0014371
2008-04-24 09:57 Vincent Snijders Target Version => 1.0.0
2008-11-05 16:56 Bart Broersma Note Added: 0023184
2009-10-20 11:20 Zeljan Rikalo Relationship added related to 0009737
2010-03-10 11:29 Zeljan Rikalo Status acknowledged => resolved
2010-03-10 11:29 Zeljan Rikalo Resolution open => fixed
2010-03-10 11:29 Zeljan Rikalo Assigned To => Zeljan Rikalo
2010-03-10 11:29 Zeljan Rikalo Note Added: 0035153
2010-03-10 15:43 Bart Broersma Status resolved => assigned
2010-03-10 15:43 Bart Broersma Resolution fixed => reopened
2010-03-10 15:43 Bart Broersma Note Added: 0035180
2010-03-10 15:50 Vincent Snijders Note Added: 0035182
2010-03-10 15:51 Vincent Snijders Note Edited: 0035182
2010-03-10 15:51 Vincent Snijders Status assigned => feedback
2010-03-10 15:56 Bart Broersma Note Added: 0035184
2010-03-10 18:29 Zeljan Rikalo Note Added: 0035194
2010-03-11 00:02 Bart Broersma Note Added: 0035215
2010-03-11 15:01 Zeljan Rikalo Note Added: 0035254
2010-03-15 19:13 Bart Broersma Note Added: 0035581
2010-03-15 19:29 Zeljan Rikalo Note Added: 0035584
2010-03-15 20:16 Flávio Etrusco (notifications not working) Note Added: 0035592
2010-03-15 20:32 José Mejuto Note Added: 0035594
2010-03-16 10:15 Zeljan Rikalo Fixed in Revision => 24030
2010-03-16 10:15 Zeljan Rikalo Status feedback => resolved
2010-03-16 10:15 Zeljan Rikalo Resolution reopened => fixed
2010-03-16 10:15 Zeljan Rikalo Note Added: 0035625
2010-03-16 16:36 Zeljan Rikalo Fixed in Revision 24030 => 24030,24043
2010-03-16 16:36 Zeljan Rikalo Widgetset GTK => GTK 2
2010-03-16 17:51 Flávio Etrusco (notifications not working) Status resolved => assigned
2010-03-16 17:51 Flávio Etrusco (notifications not working) Resolution fixed => reopened
2010-03-16 17:51 Flávio Etrusco (notifications not working) Note Added: 0035649
2010-03-16 19:58 Zeljan Rikalo Fixed in Revision 24030,24043 => 24030,24043,24048
2010-03-16 19:58 Zeljan Rikalo Status assigned => resolved
2010-03-16 19:58 Zeljan Rikalo Resolution reopened => fixed
2010-03-16 19:58 Zeljan Rikalo Note Added: 0035658
2010-03-16 22:19 Bart Broersma Status resolved => assigned
2010-03-16 22:19 Bart Broersma Resolution fixed => reopened
2010-03-16 22:19 Bart Broersma Note Added: 0035671
2010-03-16 22:39 Zeljan Rikalo Note Added: 0035672
2010-03-16 22:39 Zeljan Rikalo Status assigned => feedback
2010-03-29 15:06 Bart Broersma Note Added: 0036237
2010-06-08 19:59 Zeljan Rikalo Relationship added related to 0016678
2010-11-02 16:04 Vincent Snijders Note Added: 0042622
2010-11-03 12:37 Bart Broersma Note Added: 0042713
2010-11-03 12:50 Zeljan Rikalo Note Added: 0042715
2010-11-03 13:18 Vincent Snijders Status feedback => assigned
2012-02-04 12:07 Zeljan Rikalo LazTarget 1.0 => 1.2
2012-02-04 12:07 Zeljan Rikalo Note Added: 0056340
2012-03-13 07:50 Vincent Snijders Target Version 1.0.0 => 1.2.0
2012-03-14 18:01 Zeljan Rikalo Fixed in Revision 24030,24043,24048 => 24030,24043,24048,35982
2012-03-14 18:01 Zeljan Rikalo Status assigned => resolved
2012-03-14 18:01 Zeljan Rikalo Resolution reopened => fixed
2012-03-14 18:01 Zeljan Rikalo Note Added: 0057646
2012-03-15 18:41 Bart Broersma Status resolved => closed
2012-03-15 18:41 Bart Broersma Fixed in Version => 0.9.31 (SVN)
2016-10-10 23:39 Bart Broersma Relationship added related to 0030596