View Issue Details

IDProjectCategoryView StatusLast Update
0037557LazarusLCLpublic2020-08-19 09:33
ReporterHartmut Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSUbuntu 
Product Version2.0.6 
Summary0037557: TComboBox.AutoComplete does not work (Linux)
DescriptionTComboBox.AutoComplete does not work on Linux (on Windows the same demo works).

Versions:
 - Lazarus 2.0.6 / FPC 3.0.4 with gtk2 on Ubuntu 18.04 (64-bit) with KDE-Desktop
 - Lazarus 2.0.6 / FPC 3.0.4 on Windows 7 (32-bit)

Here is my small demo (attached):

procedure TForm1.FormActivate(Sender: TObject);
   var i: integer;
   begin
   with ComboBox1 do
      begin
      AutoComplete:=true;
      AutoCompleteText:= {adding 'cbactEndOfLineComplete' makes no difference}
         [cbactEnabled, {cbactEndOfLineComplete,} cbactSearchAscending];

      i:=2; {allows easy testing of different Styles}
      case i of
         1: Style:=csDropDown;
         2: Style:=csDropDownList;
         3: Style:=csSimple;
      end;
      writeln('Style=', Style);

      Items.Clear;
      Items.Add('1st text');
      Items.Add('2nd text');
      Items.Add('3rd text');
      ItemIndex:=0; {select first item}
      end;
   end;
Steps To Reproduce - run the attached demo on Linux (it uses TComboBox.Style=csDropDownList).
 - click on the drop-down-arrow of the ComboBox (so that the itemlist is displayed) and then press a digit key from 1..3. Nothing happens.
 - edit the demo to use TComboBox.Style=csDropDown (i=1) or csSimple (i=3) and restart the demo.
 - click on the drop-down-arrow of the ComboBox (so that the itemlist is displayed) and then press a digit key from 1..3. Nothing happens.
 - then: delete the content of the ComboBox completely and then press a digit key from 1..3. Now AutoComplete works, but this is a) very uncomfortable and b) does not work with Style=csDropDownList (which is essential for ReadOnly-Mode) and c) is not neccessary on Windows.
Additional InformationI will create a similar bug report for TComboBoxEX soon and add it's link here.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0037558 new TComboBoxEX.AutoComplete does not work (Linux) 

Activities

Hartmut

2020-08-12 19:15

reporter  

Juha Manninen

2020-08-12 19:30

developer   ~0124806

I guess this behavior is in widgetset, not in LCL.

Hartmut

2020-08-12 19:32

reporter   ~0124807

the link for a similar bug report for TComboBoxEX is https://bugs.freepascal.org/view.php?id=37558
My Widgetset is GTK2 (seems not possible to edit this field? - I'm a "reporter" only)

Hartmut

2020-08-13 11:25

reporter   ~0124826

Juha Manninen wrote:
> I guess this behavior is in widgetset, not in LCL.

I'm not familiar with widgetsets, so I don't understand exactly what your guess "means":
a) this is not a bug in the LCL, but in another part of Lazarus and so in this bug report the "Category" should be changed from "LCL" to "Widgetset" ? If yes: it seems not possible for me to change the "Category" in this report (I'm only a reporter). Can please sombebody else do this change, who has the needed rights?
or b) this is not a bug in Lazarus, but a bug in Ubuntu? Or a bug in GTK2?

If the answer is a) or b) - does this answer also apply to TComboBoxEX.AutoComplete feature which also does not work on Linux?

I testet my demo also with TComboBox.Style=csOwnerDrawFixed and csOwnerDrawVariable and the result was exactly the same as with csDropDownList (where AutoComplete does not work completely).
If I understood correctly, what jamie wrote in https://forum.lazarus.freepascal.org/index.php/topic,50933.msg373420.html#msg373420 "in owner draw mode ... means the OS does not draw it" then my last test in owner draw mode showed, that the bug is NOT in Ubuntu ???

Sorry, I'm a bloody beginner to all that stuff. Some explanaition would be very appreciated... Thanks.

wp

2020-08-13 11:43

developer   ~0124828

My 2 cents: The autocomplete function is not based on code within the LCL units, but on functions buried in the "widgetset" (you may also say: "operating system", although not exacty the same). These functions are called by the LCL and this brings AutoComplete functionality into Lazarus. Now it seems that Windows does seem to support AutoComplete, but gtk2 does not. This is a restriction like the inability to set colors or fonts in some widgetsets and should be listed on the restrictions page of the object inspector and in the restrictions browser (which is not). If AutoComplete is really needed somebody (you?) should write some code which emulates this feature for those widgetsets which do not support it natively. Alternatively you could try to use some third-party components -- I remember that there is a component in JVCL which adds autocomplete functionality to comboboxes.

Juha Manninen

2020-08-13 13:08

developer   ~0124835

Last edited: 2020-08-13 13:12

View 2 revisions

> b) this is not a bug in Lazarus, but a bug in Ubuntu? Or a bug in GTK2?

A bug or a feature in GTK2, that was my guess. I didn't study the issue now, wp likely knows more.

> Some explanaition would be very appreciated...

The strategy of LCL is to bind to "native" widgetsets, meaning Win32 API, Carbon, Cocoa, GTK*, QT5 etc.
Many other GUI libraries like GTK* and QT are custom drawn. They draw and build the behavior of their widgets themselves.
WxWidgets library follows the same idea as LCL.
This rule is a little fuzzy though. Complex controls are difficult to bind to LCL API and require lots of glue code. Some very complex ones like TreeView and the Grid components are completely custom drawn also in LCL.
So, it is possible your bug is in some LCL's glue code. You can study the code to find out. :)

TComboBoxEX also inherits from TCustomComboBox, only extending it.

Hartmut

2020-08-13 17:04

reporter   ~0124846

Thanks a lot to wp and Juha for your detailed explanations. Now I understand a little more how this stuff works together.

> If AutoComplete is really needed somebody (you?) should write some code which emulates this feature for those widgetsets which do not support it natively.
At this moment AutoComplete is only a "nice to have" for me. To write code like this is very far beyond my horizon for many years.

> Alternatively you could try to use some third-party components -- I remember that there is a component in JVCL which adds autocomplete functionality to comboboxes.
Thank you, I wrote me a notice about this and if the day comes, I will try to use it.

> So, it is possible your bug is in some LCL's glue code. You can study the code to find out. :)
I have tried numerous times to recognize something in the sources of FPC or Lazarus, but (with only 1 easy exception) always failed. Mostly there were no comments at all, and in rare cases where I found a few, they often were too short for me to understand them. And always a huge amout of unknown functions, classes, types etc. were called or used, and when I looked for them, again a huge amout of unknown things were called or used ... and after some time I was lost in an unmanageable labyrinth :-(
So I see absolutely no chance to find out something like this, maybe after many years of more experience with FPC and Lazarus.

Juha Manninen

2020-08-17 08:23

developer   ~0124940

Last edited: 2020-08-17 08:36

View 2 revisions

Does it work in other native GTK2 applications? If this is native widgetset behavior, this will be resolved as "no change required".

Anton Kavalenka

2020-08-17 18:08

reporter   ~0124951

Last edited: 2020-08-17 18:15

View 3 revisions

https://developer.gnome.org/gtk2/stable/GtkEntryCompletion.html#gtk-entry-completion-new
https://developer.gnome.org/gtk3/stable/GtkEntryCompletion.html#gtk-entry-completion-new

gtk_entry is say TEdit
GtkEntryCompletion is object managing completions inside Entry or Cell

Looks like basic autocompletion is in widgetset: lazarus/lcl/include/customcombobox.inc:536

Juha Manninen

2020-08-17 22:24

developer   ~0124957

Detaching myself. I don't have enough knowledge of the GTK2 binding code.

jamie philbrook

2020-08-18 04:26

reporter   ~0124958

I am a windows guy and I can tell you that code belongs in the widget where the TEDIT and TLIST work together to create TCombobox.

Maybe I should tune my skills for a Linux box and start pecking away on that.

Hartmut

2020-08-18 17:03

reporter   ~0124968

Juha Manninen wrote:
> Does it work in other native GTK2 applications?

Has your question already been answered by Anton Kavalenka or jamie philbrook? I don't really understand the "meaning" what they wrote.

I could test on my computer some Ubuntu applications which have ComboBoxes, but I have absolute no idea, which application uses GTKx or GTKy or QT* etc. Is there an easy way to find this out? Sorry, I'm a bloody beginner to all that stuff...

Juha Manninen

2020-08-18 19:59

developer   ~0124971

@Hartmut, yes the question was answered. That is why I left this issue open and detached myself.
GTK2 is becoming history quickly. Most applications and Linux distros have switched to GTK3. Some distros don't deliver GTK2 libraries by default any more.
I would like to see more effort in LCL-GTK3 binding.
So, if you have spare time and energy and brain capacity, please use it for LCL-GTK3 instead.

Issue History

Date Modified Username Field Change
2020-08-12 19:15 Hartmut New Issue
2020-08-12 19:15 Hartmut File Added: project1_bug_report_CB.zip
2020-08-12 19:30 Juha Manninen Note Added: 0124806
2020-08-12 19:32 Hartmut Note Added: 0124807
2020-08-13 11:25 Hartmut Note Added: 0124826
2020-08-13 11:43 wp Note Added: 0124828
2020-08-13 12:47 Juha Manninen LazTarget => -
2020-08-13 12:47 Juha Manninen Widgetset GTK => GTK 2
2020-08-13 13:08 Juha Manninen Note Added: 0124835
2020-08-13 13:12 Juha Manninen Note Edited: 0124835 View Revisions
2020-08-13 17:04 Hartmut Note Added: 0124846
2020-08-17 08:23 Juha Manninen Assigned To => Juha Manninen
2020-08-17 08:23 Juha Manninen Status new => feedback
2020-08-17 08:23 Juha Manninen Note Added: 0124940
2020-08-17 08:32 Juha Manninen Relationship added related to 0037558
2020-08-17 08:36 Juha Manninen Note Edited: 0124940 View Revisions
2020-08-17 18:08 Anton Kavalenka Note Added: 0124951
2020-08-17 18:11 Anton Kavalenka Note Edited: 0124951 View Revisions
2020-08-17 18:15 Anton Kavalenka Note Edited: 0124951 View Revisions
2020-08-17 22:24 Juha Manninen Assigned To Juha Manninen =>
2020-08-17 22:24 Juha Manninen Status feedback => new
2020-08-17 22:24 Juha Manninen Note Added: 0124957
2020-08-18 04:26 jamie philbrook Note Added: 0124958
2020-08-18 17:03 Hartmut Note Added: 0124968
2020-08-18 19:59 Juha Manninen Note Added: 0124971