How to enable search in `Gtk.DropDown`?

,

I want to enable search in Gtk.DropDown:

//  test.js
imports.gi.versions.Gtk = "4.0";
const { Gtk, GObject } = imports.gi;
Gtk.init();

var ExampleApp = GObject.registerClass(
class ExampleApp extends Gtk.Application {
    vfunc_activate() {
        let appWindow = new Gtk.ApplicationWindow({ application: this });
        
        let drop = Gtk.DropDown.new_from_strings(Array.from({ length: 30 }, (v, i) => 'opt' + i));
        log(drop.get_model());
        drop.set_enable_search(true);
        appWindow.set_child(drop);

        appWindow.set_default_size(200, 200);
        appWindow.present();
    }
});
new ExampleApp().run([imports.system.programInvocationName].concat(ARGV));

There should be only one item opt3 left when searching in the box, but nothing happens. It should work for the Gtk.StringList model even without set_expression as promised. If not, how can I do that? Thanks in advance!

The promise has an exception, here:
https://gitlab.gnome.org/GNOME/gtk/-/blob/master/gtk/gtkdropdown.c#L491-497

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.