Clear button for Entry

Can’t find with debugger, how this feature implemented in GNOME browser:
image

Is this native element for GtkEntry or AdwEntryRow?

Can’t find with debugger,

Refer https://docs.gtk.org/gtk4/running.html#interactive-debugging.

You can achieve clearing text with GtkEntry. Refer main/gtk/gtksearchentry.c#L142 to see how this is done for a GtkSearchEntry.

Below are quick examples to look into.

Screenshot from gtk4-widget-factory:

gtk-widget-factory-entry

Screenshot from gtk4-demo:

gtk-demo-entry

2 Likes

The easiest way is to use Gtk.Entry.set_icon_from_icon_name to easily show an icon at start or end of the entry.
You can catch click events by connecting to Gtk.Entry::icon-press .

The “Tagged Entry” demo is a good example if you need something more complex/customizable.

1 Like

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