View Issue Details

IDProjectCategoryView StatusLast Update
0037116LazarusWidgetsetpublic2020-10-31 05:49
ReporterJohn McClane Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.0.6 
Summary0037116: TEdit and Backspace
Description2.0.6 3.0.4
When I press Control + Backspace, It doesn't delete one word as it is expected.
Control + Delete is working.
I'm using Lazarus 2.0.6 with FPC 3.0.4 on Ubuntu 18.04 "BIonic"
It worked with older Linuxes and versions.
Thanks in advance. Have a nice day.

* I wanted to attach a very tiny program but it surpasses 2 Mb, sory-
Steps To ReproduceWrite two words on a TEdit and press control + backspace when the caret is at the end of the sentence.
TagsNo tags attached.
Fixed in Revisionr63519
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0032630 closedJuha Manninen [patch] Gtk2 TEdit/TMemo: fix text selection, make OnChange event compatible with LCL-Win32 

Activities

Bart Broersma

2020-05-19 20:33

developer   ~0122939

Ctrl+Backspace has never worked like that in Windows IIRC (it also does not work that way in Delphi 7).
Since a TEdit basically is a native control, I would suspect that this behaviour is cotrolled by the underlying widgetset.

OTOH, if you know a revision where it worked, you can bisect to find the guilty revision.

John McClane

2020-05-21 17:43

reporter   ~0122984

I'm sure it worked before on Linux and Windows. I used that feature, and I have an old program which is working.
I don't understand what you're saying by 'bisect'.

jamie philbrook

2020-05-21 18:50

reporter   ~0122987

I agree with Bart, I just checked two of my windows PC's and the Control+backspace does nothing but insert some Unicode characters in there.

 Are you sure you didn't enhance the keyboard editing via the OnKeyDown or up ? that can be done.

Btw, I did the test on Lazarus and Delphi 10.x
 
 I guess it could be a possible issue when full Unicode took over.
What did you compile your old app in ?

John McClane

2020-05-21 19:26

reporter   ~0122990

No I didn't enhance my keyboard and I don't remember what version of Lazarus I used, but I'm not talking about Windows, I'm talking about Linux.

Juha Manninen

2020-05-21 20:37

developer   ~0122993

About bisecting:
https://wiki.lazarus.freepascal.org/How_do_I_create_a_bug_report#Regression_caused_by_a_certain_revision

Bart Broersma

2020-06-28 22:21

developer   ~0123658

@zeljan: any thoughts on this: as far as you know, did this ever work like John says?

Zeljan Rikalo

2020-06-29 11:04

developer   ~0123664

@Bart, I can't remember, maybe in gtk1 or in some older gtk2 lib version it was so.

Bart Broersma

2020-06-29 14:55

developer   ~0123666

Did we pri=ovide such a binding, or did the WS this "by itself"?
If the latter, then this can be resolved as "no change required".

Joeny Ang

2020-06-30 05:50

reporter   ~0123672

Hi, the Ctrl+Backspace/Delete is a feature present in both QT and GTK. Currently on GTK2, Ctrl+Backspace works on TEdit when the cursor is not at the end of the string. It even works on TComboBox and TMemo. After some digging, the change was introduced in r56287. In gtk2callback.inc, there is a check in gtkchanged_editbox_delete() function which cancels the delete-from-cursor signal when the cursor is at the end. Removing the check fixes the problem. But, I am not sure what that check is for, though. :)
tedit-ctrl-backspace-v1.patch (749 bytes)   
--- lcl/interfaces/gtk2/gtk2callback.inc
+++ lcl/interfaces/gtk2/gtk2callback.inc
@@ -498,20 +498,8 @@
 
 function gtkchanged_editbox_delete(widget: PGtkWidget;
   AType: TGtkDeleteType; APos: gint; data: gPointer): GBoolean; cdecl;
-var
-  EntryText: PgChar;
 begin
   Result := CallBackDefaultReturn;
-  if GTK_IS_ENTRY(Widget) then
-  begin
-    EntryText := gtk_entry_get_text(PGtkEntry(Widget));
-    if (PGtkEntry(Widget)^.current_pos = PGtkEntry(Widget)^.selection_bound)
-    and (PGtkEntry(Widget)^.current_pos = UTF8Length(EntryText)) then
-    begin
-      g_signal_stop_emission_by_name(Widget, 'delete-from-cursor');
-      Exit;
-    end;
-  end;
 end;
 
 function gtkdaychanged(Widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;

Juha Manninen

2020-06-30 11:37

developer   ~0123676

Thanks Joeny Ang.
r56287 was a patch from accorp some 2.5 years ago, related to text selection etc.
It resolved quite many bug reports. The change in function gtkchanged_editbox_delete() was only a small part of it.
Could you please test that your patch does not create regressions for the related issue. I have no time to test now.

Joeny Ang

2020-07-06 10:42

reporter   ~0123769

Last edited: 2020-07-06 10:45

View 3 revisions

Hi, the check was actually to prevent OnChange() from being fired when the Delete key is pressed while the caret is at the end or the text is empty.

Patch: Moved the check to gtkchanged_editbox_delete_text()

Also tested with the test project of accorp from Issue 0032630. Everything checks out except for 2 tests that are CharCase related. I'll open a new ticket on this.

I think we can remove gtkchanged_editbox_delete() already? :)
tedit-ctrl-backspace-v2.patch (1,113 bytes)   
--- lcl/interfaces/gtk2/gtk2callback.inc
+++ lcl/interfaces/gtk2/gtk2callback.inc
@@ -424,6 +424,13 @@
 var
   id: gPointer;
 begin
+  // delete key pressed, but nothing is deleted (eg. cursor at the end or empty text)
+  if AStartPos = AEndPos then
+  begin
+    g_signal_stop_emission_by_name(Widget, 'delete-text');
+    Exit;
+  end;
+
   id := g_object_get_data(PGObject(Widget), 'lcl-postpone-changed-signal');
   if id = nil then
   begin
@@ -498,20 +505,8 @@
 
 function gtkchanged_editbox_delete(widget: PGtkWidget;
   AType: TGtkDeleteType; APos: gint; data: gPointer): GBoolean; cdecl;
-var
-  EntryText: PgChar;
 begin
   Result := CallBackDefaultReturn;
-  if GTK_IS_ENTRY(Widget) then
-  begin
-    EntryText := gtk_entry_get_text(PGtkEntry(Widget));
-    if (PGtkEntry(Widget)^.current_pos = PGtkEntry(Widget)^.selection_bound)
-    and (PGtkEntry(Widget)^.current_pos = UTF8Length(EntryText)) then
-    begin
-      g_signal_stop_emission_by_name(Widget, 'delete-from-cursor');
-      Exit;
-    end;
-  end;
 end;
 
 function gtkdaychanged(Widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;

tedit-ctrl-backspace-v2.patch (1,113 bytes)   

Juha Manninen

2020-07-06 11:44

developer   ~0123773

I applied the patch. Thanks.

> Also tested with the test project of accorp from Issue 0032630. Everything checks out except for 2 tests that are CharCase related. I'll open a new ticket on this.

Ok. I will resolve this one.

> I think we can remove gtkchanged_editbox_delete() already? :)

No, it cannot removed because it is used as an event callback.

Issue History

Date Modified Username Field Change
2020-05-19 20:00 John McClane New Issue
2020-05-19 20:33 Bart Broersma Note Added: 0122939
2020-05-21 17:43 John McClane Note Added: 0122984
2020-05-21 18:50 jamie philbrook Note Added: 0122987
2020-05-21 19:26 John McClane Note Added: 0122990
2020-05-21 20:37 Juha Manninen Note Added: 0122993
2020-06-28 22:21 Bart Broersma Category LCL => Widgetset
2020-06-28 22:21 Bart Broersma LazTarget => -
2020-06-28 22:21 Bart Broersma Widgetset GTK 2 => GTK 2
2020-06-28 22:21 Bart Broersma Note Added: 0123658
2020-06-29 11:04 Zeljan Rikalo Note Added: 0123664
2020-06-29 14:55 Bart Broersma Note Added: 0123666
2020-06-30 05:50 Joeny Ang Note Added: 0123672
2020-06-30 05:50 Joeny Ang File Added: tedit-ctrl-backspace-v1.patch
2020-06-30 11:30 Juha Manninen Relationship added related to 0032630
2020-06-30 11:33 Juha Manninen Assigned To => Juha Manninen
2020-06-30 11:33 Juha Manninen Status new => assigned
2020-06-30 11:37 Juha Manninen Note Added: 0123676
2020-07-06 10:42 Joeny Ang Note Added: 0123769
2020-07-06 10:42 Joeny Ang File Added: tedit-ctrl-backspace-v2.patch
2020-07-06 10:44 Joeny Ang Note Edited: 0123769 View Revisions
2020-07-06 10:45 Joeny Ang Note Edited: 0123769 View Revisions
2020-07-06 11:44 Juha Manninen Status assigned => resolved
2020-07-06 11:44 Juha Manninen Resolution open => fixed
2020-07-06 11:44 Juha Manninen Fixed in Revision => r63519
2020-07-06 11:44 Juha Manninen Widgetset GTK 2 => GTK 2
2020-07-06 11:44 Juha Manninen Note Added: 0123773