View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0031618 | Lazarus | Widgetset | public | 2017-03-31 16:49 | 2018-09-13 21:32 |
Reporter | Vojtech Cihak | Assigned To | Juha Manninen | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | amd64 | OS | Linux | ||
Product Version | 1.7 (SVN) | ||||
Summary | 0031618: TSpinEdit.OnChange events in GTk2 | ||||
Description | Issues of TSpinEdit.OnChange and TFloatSpinEdit.OnChange events in GTk2: 1) Events are triggered on program startup. It does not happen in LCL-Qt nor in Delphi 7. 2) TFloatSpinEdit .OnChange is triggered twice (change by key, mouse or code). It does not happen in LCL-Qt nor in Delphi 7. | ||||
Steps To Reproduce | Run demo. You will see: SpinEdit1OnChange FloatSpinEdit2OnChange SpinEdit2OnChange FloatSpinEdit1OnChange FloatSpinEdit2OnChange Try change value of any FloatSpinEdit by key or mouse. OnChange is triggered twice. Push button [ +1 ]. It increments 1 to all spinedits. You will see: FloatSpinEdit1OnChange FloatSpinEdit2OnChange SpinEdit1OnChange SpinEdit2OnChange FloatSpinEdit1OnChange FloatSpinEdit2OnChange | ||||
Additional Information | Lazarus 1.7 r51977:54499M FPC 3.0.2 x86_64-linux-qt | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
LazTarget | - | ||||
Widgetset | GTK 2 | ||||
Attached Files |
|
related to | 0018679 | closed | Zeljan Rikalo | Lazarus | wrong behaviour of TFloatSpinEdit at Keyboard input |
related to | 0032196 | closed | Juha Manninen | Lazarus | BorderSpacing changes byt itself when multi-selecting components |
related to | 0032975 | resolved | Juha Manninen | Lazarus | A patch for fixing OnChange of TFloatSpinEdit and TSpinEdit is triggered but nothing changed when TForm.Show with gtk2 |
related to | 0032669 | new | Packages | OnChange event couldnāt be triggered correctly when using Memo1.ClearSelection | |
related to | 0032602 | confirmed | Lazarus | TEdit.OnChange event handler is calling twice for same text | |
related to | 0032368 | new | Lazarus | TFloatSpinEdit emits dealyed secondary OnChange on Value change when DecimalPlaces=0 |
|
|
|
> r51977:54499M You have local modifications, does this also happen if you revert these? |
|
Yes, I just updated and reverted changes and it still happens. Lazarus 1.9.0 r54600M FPC 3.0.2 x86_64-linux-qt |
|
> Lazarus 1.9.0 r54600M FPC 3.0.2 x86_64-linux-qt The M means you stil have modifications. And you confuse me, because you stated that this is a GTK2 issue? |
|
I reverted local changes more precisely. Now: Lazarus 1.9.0 r54603 FPC 3.0.2 x86_64-linux-gtk2 Lazarus itself is Qt app. Demo compiled as a GTk2 app makes issue. Demo as a Qt app works fine. |
|
Here's what happens when I click the up-arrow (FSE is a TFloatSpinEdit): gtkchanged_spinbox gtkchanged_spinbox FSE.OnChange: Value = 0.0, Text = 0.00 //this is the old value FSE.OnChange: Value = 0.0, Text = 0.00 gtkchanged_spinbox gtkchanged_spinbox FSE.OnChange: Value = 1.0, Text = 1.00 FSE.OnChange: Value = 1.0, Text = 1.00 gtkchanged_editbox gtkchanged_editbox FSE.OnChange: Value = 1.0, Text = 1.00 Then when I leave the control: gtkchanged_spinbox gtkchanged_spinbox FSE.OnChange: Value = 1.0, Text = 1.00 FSE.OnChange: Value = 1.0, Text = 1.00 So, there are 2 signals that cause an OnChange: the change in Text and the change in Value. For a TSpinEdit it is gtkchanged_spinbox gtkchanged_editbox gtkchanged_editbox SE.OnChange: Value = 2.0, Text = 2 No additional change signals when I leave the control. |
|
The fix for 0018679 (r36095) introduces this behaviour. When my TFloatSpinEdit (2 digits) has value 99.00 (Text 99,00) and I press the up arrow this is what happens: In gtkchanged_spinbox; .. //SValue = '99.00' ADecimalSeparator = '.' if (Pos(ADecimalSeparator, SValue) > 0) and (length(SValue) > 1) then begin SNewValue := Copy(SValue,Pos(ADecimalSeparator, SValue) + 1, length(SValue)); while length(SNewValue) > NumDigits do begin Delete(SValue, length(SValue), 1); inc(NumDigits); end; end; After that SNewValue will be '00' and then if SNewValue <> SValue then gtk_entry_set_text(PGtkEntry(Widget), PChar(SValue)); And this will trigger further 'value-changed' triggers that will ultimately cause OnChange events to happen. This part of the code is only executed if DecimalPlaces > 0, so the TSpinEdit will not sufer from this bug. |
|
Some of the superfluous OnChanges can be fixed by changing the logic to TextDigits := Length(Copy(SValue,Pos(ADecimalSeparator, SValue) + 1, length(SValue))); if (TextDigits > NumDigits) then begin Delete(SValue, length(SValue) - (TextDigits-NumDigits-1), (TextDigits-NumDigits)); end; As far as I understand this code, it is used to eliminate extra digits the user types in the control. E.g. Text is 12.34, DecimalPlaces = 2, and user types a digit (e.g. 5) with cursor at end of the text In this scenario SValue (text retrieved from the control) will be 12.345, and the code will trim that down to 12.34 again. At least with this fix typing in the control reduces the number of OnChanges to 1 per typed character. Incrementing the value (cicking the up-arrow) will however first send a gtkchanged_spinbox and later a gtkchanged_spinbox, and I still get 2 OnChanges. |
|
This is getting silly: I increment my TFloatSpinEdit (use up-arrow of the keyboard) from 99.00 to 100.00 gtkchanged_spinbox A gtkchanged_spinbox F SValue: "99.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "99.00" <> SNewValue: "00" call: gtk_entry_set_text *** FSE.OnChange: Value = 99.0000, Text = 99.00 *** FSE.OnChange: Value = 99.0000, Text = 99.00 gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text *** FSE.OnChange: Value = 100.0000, Text = 100.00 *** FSE.OnChange: Value = 100.0000, Text = 100.00 gtkchanged_editbox gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text *** FSE.OnChange: Value = 100.0000, Text = 100.00 *** FSE.OnChange: Value = 100.0000, Text = 100.00 gtkchanged_editbox *** FSE.OnChange: Value = 100.0000, Text = 100.00 gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text 7 OnChanges. Doing the same with the mouse (clicking the up-arrow of the control) gives: gtkchanged_spinbox A gtkchanged_spinbox F SValue: "99.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "99.00" <> SNewValue: "00" call: gtk_entry_set_text *** FSE.OnChange: Value = 99.0000, Text = 99.00 *** FSE.OnChange: Value = 99.0000, Text = 99.00 gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text *** FSE.OnChange: Value = 100.0000, Text = 100.00 *** FSE.OnChange: Value = 100.0000, Text = 100.00 gtkchanged_editbox gtkchanged_editbox *** FSE.OnChange: Value = 100.0000, Text = 100.00 gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text gtkchanged_spinbox A gtkchanged_spinbox F SValue: "100.00" <> SNewValue: "00" call: gtk_entry_set_text 5 OnChanges |
|
What a mess. With my patch: - increment (use up-key or up-arrow): 2 OnChanges - delete one character: 1 OnChange - increment after you deleted one character: 3 OnChanges At least exiting the control does not fire an OnChange anymore. B.t.w. I would have expected that deleting a character would fire a gtkchanged_editbox, but it only fires gtkchanged_spinbox. |
|
Can you please try with r55630. On my system it reduces the amount of OnChanges to 1 per change, wether you edit, or increment/decrement. The OnChange at program start still remains however. Also the following sequnce will produce 3 onChanges, where 2 are expected: Delete one character in the control (1 OnChange), then increment or decrement (2 OnChanges). PS I'm on Linux Mint 18.0-64-bit. GTK 2.24.30 I uloaded a simple test program (spin.zip) that counts the OnChanges of the TFloatSpinEdit. You can reset the counter to zero by pressing Ctrl+D (this will also write some empty lines to the console). |
|
|
|
My test with Lazarus 1.9.0 r55743 FPC 3.0.2 x86_64-linux-qt: Demo in GTk2: 1) OnChange at program start remains (no OnChange in Qt) 2a) Deleting character (0.50 -> 0.5) triggers OnChange (it is in Qt too) 2b) Then increment or decrement triggers two OnChanges (only one in Qt) 3) Pushing button [+1] triggers only one OnChange for each SpinEdit, but out of order: GTk2: FloatSpinEdit1OnChange FloatSpinEdit2OnChange SpinEdit1OnChange SpinEdit2OnChange Expected order (as it is in Qt): SpinEdit1OnChange SpinEdit2OnChange FloatSpinEdit1OnChange FloatSpinEdit2OnChange |
|
Well, I did not touch QT, only GTK2. Is GTK2 now better, worse or unchanged for you. For me it is better, but definitvely not fixed. If it is better for you on GTK2 as well, we'll merge it into 1.8 release. SpinEdit on GTK2 is a nasty control (at least the way it is implemented now) IMO. Alternatively you can use T(Float)SpinEditEx (unit LazControls). It should have less issues. |
|
I wouldn't merge anything now. But both SpiEdits on GTk2 didn't behave this way in past. There has to be revision that broked it (I don't believe it was r.360xx, it had to be later). |
|
@ The fix for 0018679 (r36095) introduces this behaviour. I misunderstood your post from 2017-07-31 13:12, you made typo. It was report https://bugs.freepascal.org/view.php?id=30596 , not 36095. So the revision that introduced OnChange events on program startup was 53653 by Juha: https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/gtk2/gtk2callback.inc?root=lazarus&r1=53653&r2=53652&pathrev=53653 The issue for double OnChange of TFloatSpinEdit is there for ages, definitely pre r.51000. |
|
Uhhh... How to fix it? I would like to leave it for somebody else. |
|
Resolved in meanwhile? I saw today closed issue 32985 and I tried again SpinEditGTk demo. I cannot reproduce with Lazarus 1.9.0 r57588M FPC 3.0.4 x86_64-linux-qt. I'd like to ask others to test, if OK we can close this. Thanks |
|
Ok, resolving. |
|
I tested again with Lazarus 1.9.0 r58967M FPC 3.3.1 x86_64-linux-qt Works well. I close. |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-03-31 16:49 | Vojtech Cihak | New Issue | |
2017-03-31 16:49 | Vojtech Cihak | File Added: SpinEditGTk.zip | |
2017-04-08 14:41 | Bart Broersma | LazTarget | => - |
2017-04-08 14:41 | Bart Broersma | Note Added: 0099502 | |
2017-04-08 14:41 | Bart Broersma | Status | new => feedback |
2017-04-10 20:05 | Vojtech Cihak | Note Added: 0099547 | |
2017-04-10 20:05 | Vojtech Cihak | Status | feedback => new |
2017-04-10 21:58 | Bart Broersma | Note Added: 0099549 | |
2017-04-11 16:30 | Vojtech Cihak | Note Added: 0099561 | |
2017-07-31 12:07 | Bart Broersma | Note Added: 0102006 | |
2017-07-31 12:07 | Bart Broersma | Note Edited: 0102006 | View Revisions |
2017-07-31 13:03 | Bart Broersma | Relationship added | related to 0018679 |
2017-07-31 13:12 | Bart Broersma | Note Added: 0102007 | |
2017-07-31 14:14 | Bart Broersma | Note Added: 0102008 | |
2017-07-31 14:14 | Bart Broersma | Note Edited: 0102008 | View Revisions |
2017-07-31 14:14 | Bart Broersma | Note Edited: 0102008 | View Revisions |
2017-08-01 00:15 | Bart Broersma | Note Edited: 0102008 | View Revisions |
2017-08-01 01:20 | Bart Broersma | Note Added: 0102022 | |
2017-08-01 01:20 | Bart Broersma | Note Edited: 0102022 | View Revisions |
2017-08-01 23:13 | Bart Broersma | Note Added: 0102026 | |
2017-08-02 18:14 | Bart Broersma | Note Added: 0102040 | |
2017-08-02 18:14 | Bart Broersma | Status | new => feedback |
2017-08-02 18:16 | Bart Broersma | File Added: spin.zip | |
2017-08-02 18:17 | Bart Broersma | Note Edited: 0102040 | View Revisions |
2017-08-02 18:18 | Bart Broersma | Note Edited: 0102040 | View Revisions |
2017-08-25 03:27 | Vojtech Cihak | Note Added: 0102357 | |
2017-08-25 03:27 | Vojtech Cihak | Status | feedback => new |
2017-08-25 22:13 | Bart Broersma | Note Added: 0102382 | |
2017-08-25 22:13 | Bart Broersma | Status | new => feedback |
2017-08-25 22:14 | Bart Broersma | Note Edited: 0102382 | View Revisions |
2017-08-26 01:41 | Vojtech Cihak | Note Added: 0102384 | |
2017-08-26 01:41 | Vojtech Cihak | Status | feedback => new |
2017-08-26 14:14 | Vojtech Cihak | Note Added: 0102391 | |
2017-08-26 14:15 | Vojtech Cihak | Note Edited: 0102391 | View Revisions |
2017-08-26 14:44 | Juha Manninen | Note Added: 0102392 | |
2017-09-04 23:07 | Bart Broersma | Relationship added | related to 0032368 |
2018-01-04 18:30 | Juha Manninen | Relationship added | related to 0032196 |
2018-01-08 17:47 | Bart Broersma | Relationship added | related to 0032975 |
2018-04-01 16:15 | Vojtech Cihak | Note Added: 0107513 | |
2018-09-05 17:40 | Juha Manninen | Relationship added | related to 0032669 |
2018-09-05 17:41 | Juha Manninen | Relationship added | related to 0032602 |
2018-09-11 00:40 | Juha Manninen | Note Added: 0110630 | |
2018-09-11 00:40 | Juha Manninen | Status | new => resolved |
2018-09-11 00:40 | Juha Manninen | Resolution | open => fixed |
2018-09-11 00:40 | Juha Manninen | Assigned To | => Juha Manninen |
2018-09-13 21:32 | Vojtech Cihak | Note Added: 0110726 | |
2018-09-13 21:32 | Vojtech Cihak | Status | resolved => closed |