I have Gtk.ListBox
with Adw.EntryRow
s 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)
Sid
(Sid)
November 10, 2024, 3:06am
2
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.
Sid
(Sid)
November 10, 2024, 2:06pm
5
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
Sid
(Sid)
November 10, 2024, 2:49pm
6
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
system
(system)
Closed
December 10, 2024, 2:49pm
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.