View Issue Details

IDProjectCategoryView StatusLast Update
0034678LazarusWidgetsetpublic2020-03-27 15:18
ReporterArtem ProskurnevAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionreopened 
Platformx64OSLinuxOS VersionAltlinux p8
Product Version1.8.4Product Build2018-11-25 
Target VersionFixed in Version 
Summary0034678: TMaskEdit sometimes skips characters
DescriptionIf you run the program and start typing numbers (mask '99999999999;1;_'), sometimes the cursor will jump to the forward field.
http://apsik.ru/mask.ogv

Lazarus 1.8.4 rUnversioned directory FPC 3.0.4 x86_64-linux-gtk2
Steps To ReproduceUntar and compile test project.
TagsNo tags attached.
Fixed in Revisionr62806
LazTarget-
WidgetsetGTK 2
Attached Files
  • maskedit.tar.gz (1,412 bytes)
  • gtk2wsstdctrls.diff (701 bytes)
    Index: /home/percy/Desenvolvimento/Lazarus/bin/Trunc/lazarus/lcl/interfaces/gtk2/gtk2wsstdctrls.pp
    ===================================================================
    --- /home/percy/Desenvolvimento/Lazarus/bin/Trunc/lazarus/lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(revisão 62775)
    +++ /home/percy/Desenvolvimento/Lazarus/bin/Trunc/lazarus/lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(cópia de trabalho)
    @@ -1419,8 +1419,8 @@
         g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo)
       else
         gtk_entry_select_region(Entry,
    -      SelStart,
    -      SelStart + NewLength);
    +      SelStart+ NewLength,
    +      SelStart );
     end;
     
     class procedure TGtk2WSCustomEdit.SetAlignment(const ACustomEdit: TCustomEdit;
    
    gtk2wsstdctrls.diff (701 bytes)

Relationships

related to 0023459 resolvedBart Broersma TMaskEdit skips characters 
related to 0020890 resolvedZeljan Rikalo Wrong usage of SelStart and SelLength in OnChange event 
has duplicate 0036815 resolvedBart Broersma gtk2 TmaskEdit 

Activities

Artem Proskurnev

2018-12-11 02:36

reporter  

maskedit.tar.gz (1,412 bytes)

Bart Broersma

2018-12-11 18:40

developer   ~0112492

Did we discuss this previously on forum or mailinglist?
IIRC I had a discussion over a similar unreproducable issue.

Bart Broersma

2018-12-11 18:44

developer   ~0112493

Seems to be the same as 0023459?
Please look at how this ws solve by the reporter, it may apply to your situation.

Bart

Artem Proskurnev

2018-12-11 20:30

reporter   ~0112494

I use KDE5. The problem is very rare, but still appears (the video happened quite often). qtcurve for gtk2 is installed. If you select qt4 or qt5, the problem is not observed.

Bart Broersma

2018-12-11 21:03

developer   ~0112495

I have tried to reproduce this on my Linux Mint 18.2 (64-bit), but was unsuccessfull.
The code that moves the selection after you entered a character (InsertChar method) is in SelectNextChar() method.

You could add some debugln statements inside InsertChar, SelectNextChar and SetCursorPos to see if FCursorPos is what you expect it to be.

Artem Proskurnev

2019-03-12 21:18

reporter   ~0114802

OS problem, Resolved. Install gtk2-themes-qtcurve :-)

Bart Broersma

2019-03-12 22:54

developer   ~0114804

As per original reporter.

Thanks for reporting back.
Please close.

Artem Proskurnev

2020-02-21 21:22

reporter   ~0121186

The problem is back. It does not help anything. I added the following code to make it work:
MaskEdit.pp
==========
// Single key down procedure
procedure TCustomMaskEdit.KeyDown(var Key: Word; Shift: TShiftState);
begin
  Inherited KeyDown(Key, Shift);
  // Not masked -> old procedure
  if not IsMasked then
  begin
    Exit;
  end;
/////+++++++++++++++++
  if SelLength=0 then
    SetSel(FCursorPos, FCursorPos+1);
/////+++++++++++++++++
  FCursorPos := GetSelStart;
  // shift and arrowkey -> old procedure
  if (ssShift in Shift) then
  begin
    if (Key = VK_LEFT) or (Key = VK_RIGHT) or
       (Key = VK_HOME) or (Key = VK_END) then

Bart Broersma

2020-02-22 14:16

developer   ~0121192

This has to be solved on the WS side, and I have no idea how to do that.
It may also be a bug in your distro's version of GTK2.

Artem Proskurnev

2020-02-26 18:08

reporter   ~0121235

I can make and upload a virtual machine with my distribution...

Percy Van Den Bylaardt

2020-03-20 20:43

reporter   ~0121668

"gtk_entry_select_region" is the problem,

when more than one character is selected, the caret moves to the position of the third parameter,
so, reversing the second and third parameters may be enough.

gtk2wsstdctrls.diff (701 bytes)
Index: /home/percy/Desenvolvimento/Lazarus/bin/Trunc/lazarus/lcl/interfaces/gtk2/gtk2wsstdctrls.pp
===================================================================
--- /home/percy/Desenvolvimento/Lazarus/bin/Trunc/lazarus/lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(revisão 62775)
+++ /home/percy/Desenvolvimento/Lazarus/bin/Trunc/lazarus/lcl/interfaces/gtk2/gtk2wsstdctrls.pp	(cópia de trabalho)
@@ -1419,8 +1419,8 @@
     g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo)
   else
     gtk_entry_select_region(Entry,
-      SelStart,
-      SelStart + NewLength);
+      SelStart+ NewLength,
+      SelStart );
 end;
 
 class procedure TGtk2WSCustomEdit.SetAlignment(const ACustomEdit: TCustomEdit;
gtk2wsstdctrls.diff (701 bytes)

Bart Broersma

2020-03-22 13:09

developer   ~0121682

@Zeljan: can you take a look at proposed patch?

Juha Manninen

2020-03-25 11:02

developer   ~0121703

Last edited: 2020-03-25 11:51

View 2 revisions

Please test with r62806.
I applied the patch from Percy Van Den bylaardt. It works. Thanks!
I also removed the delayed SetSelLength which in my tests didn't show any difference now. See related 0020890.
It may depend on GTK2 version and needs testing.

[Edit]
In r62807 I also removed the delayed SetSelStart, function gtk2WSDelayedSelStart().
Please test.

Percy Van Den Bylaardt

2020-03-27 15:17

reporter   ~0121732

works fine. Tested on GTK 2.24 for linux.

Issue History

Date Modified Username Field Change
2018-12-11 02:36 Artem Proskurnev New Issue
2018-12-11 02:36 Artem Proskurnev File Added: maskedit.tar.gz
2018-12-11 18:40 Bart Broersma Note Added: 0112492
2018-12-11 18:40 Bart Broersma LazTarget => -
2018-12-11 18:40 Bart Broersma Assigned To => Bart Broersma
2018-12-11 18:40 Bart Broersma Status new => feedback
2018-12-11 18:44 Bart Broersma Note Added: 0112493
2018-12-11 18:44 Bart Broersma Relationship added related to 0023459
2018-12-11 20:30 Artem Proskurnev Note Added: 0112494
2018-12-11 20:30 Artem Proskurnev Status feedback => assigned
2018-12-11 21:03 Bart Broersma Note Added: 0112495
2019-03-12 21:18 Artem Proskurnev Note Added: 0114802
2019-03-12 22:54 Bart Broersma Note Added: 0114804
2019-03-12 22:54 Bart Broersma Status assigned => resolved
2019-03-12 22:54 Bart Broersma Resolution open => no change required
2020-02-21 21:22 Artem Proskurnev Status resolved => assigned
2020-02-21 21:22 Artem Proskurnev Resolution no change required => reopened
2020-02-21 21:22 Artem Proskurnev Note Added: 0121186
2020-02-22 14:16 Bart Broersma Note Added: 0121192
2020-02-22 14:16 Bart Broersma Assigned To Bart Broersma =>
2020-02-22 14:16 Bart Broersma Status assigned => acknowledged
2020-02-26 18:08 Artem Proskurnev Note Added: 0121235
2020-03-20 20:43 Percy Van Den Bylaardt File Added: gtk2wsstdctrls.diff
2020-03-20 20:43 Percy Van Den Bylaardt Note Added: 0121668
2020-03-21 12:33 Bart Broersma Relationship added has duplicate 0036815
2020-03-22 13:08 Bart Broersma Category LCL => Widgetset
2020-03-22 13:08 Bart Broersma Widgetset GTK 2 => GTK 2
2020-03-22 13:09 Bart Broersma Note Added: 0121682
2020-03-25 10:19 Juha Manninen Relationship added related to 0020890
2020-03-25 10:19 Juha Manninen Assigned To => Juha Manninen
2020-03-25 10:19 Juha Manninen Status acknowledged => assigned
2020-03-25 11:02 Juha Manninen Status assigned => feedback
2020-03-25 11:02 Juha Manninen Note Added: 0121703
2020-03-25 11:03 Juha Manninen Fixed in Revision => r62806
2020-03-25 11:03 Juha Manninen Widgetset GTK 2 => GTK 2
2020-03-25 11:51 Juha Manninen Note Edited: 0121703 View Revisions
2020-03-27 15:17 Percy Van Den Bylaardt Note Added: 0121732