How to trigger action on Adw.EntryRow selection?

I have Gtk.ListBox with Adw.EntryRows in it. How can I check if entry row selected to perform some action?

A piece of code:

def __init__(self, **kwargs):
    ...
    self.lyrics_lines_box.connect('row-selected', self.update_selected_row)
    ...
def update_selected_row(self, box, row):
    shared.shared.selected_row = row
    print(shared.shared.selected_row)

For AdwEntry activation:

For GtkListBox, row selection:

I’ve already tried these methods, but none of them working.

row-selected is working only if clicked to pen icon at the end of Adw.EntryRow. If just click to field, signal doesn’t emit.

If you read Adw – 1: Boxed Lists you’ll notice that GtkListBox’s selection-mode property should be set to Gtk.SelectionMode.NONE when creating boxed lists.

So I think libadwaita’s rows aren’t intended to be used with selection, especially
Adw.EntryRow that needs to grab the focus for editing.

FWIW, entry-activated is not emitted even if AdwEntryRow is outside a GtkListBox. I’m just checking with latest GTK / libadwaita to confirm this.

1 Like

Correction. entry-activated is used for capturing Enter key press (which works as expected), and not selection.

For focus / selection events I think one should use EventControllerFocus.

1 Like

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