GTK3: Fixed selected item text returned by ComboBox Text property.

We need to use `GtkEntry` for comboboxes with `has_entry = True` and
set the `column_id` property.

Closes #40706
This commit is contained in:
Abou Al Montacir 2024-01-21 19:29:45 +01:00
parent 94d8b3f878
commit e45713b7f8

View File

@ -6754,7 +6754,7 @@ begin
// PGtkEventBox(Result)^.set_visible_window(True);
end;
g_object_unref(ListStore);
PGtkComboBox(Result)^.set_id_column(0);
end;
function TGtk3ComboBox.EatArrowKeys(const AKey: Word): Boolean;
@ -6764,15 +6764,29 @@ end;
function TGtk3ComboBox.getText: String;
begin
Result := inherited getText;
if Gtk3IsComboBox(GetContainerWidget) then
Result := StrPas(PGtkComboBox(GetContainerWidget)^.get_title);
Result := '';
if Gtk3IsComboBox(GetContainerWidget) then begin
with PGtkComboBox(GetContainerWidget)^ do begin
if has_entry then begin
Result := StrPas(PGtkEntry(get_child)^.Text);
end else begin
Result := active_id;
end;
end;
end;
end;
procedure TGtk3ComboBox.setText(const AValue: String);
begin
if Gtk3IsComboBox(FWidget) then
PGtkComboBox(GetContainerWidget)^.set_title(PgChar(AValue));
if Gtk3IsComboBox(GetContainerWidget) then begin
with PGtkComboBox(GetContainerWidget)^ do begin
if has_entry then begin
PGtkEntry(get_child)^.Text := Pgchar(AValue);
end else begin
//active_id := Pgchar(AValue); TODO: Wait until property becomes writeble
end;
end;
end;
end;
procedure TGtk3ComboBox.DumpPrivateStructValues(const ADbgEvent: String);