How to trigger an action on the AdwActionRow component

I’m trying to call a function when I click on an AdwActionRow element.

As of Adw.ActionRow :

AdwActionRow is unactivatable by default, giving it an activatable widget will automatically make it activatable, but unsetting it won’t change the row’s activatability.

Here is commented code:

## Here I create the ActionRow from an XML response
ActionRow = Adw.ActionRow(
    icon_name="list-drag-handle-symbolic",
    activatable="true",
    title=child.find('name').text,
    subtitle=(child.find('lastMessage')).find('message').text[:14]
)

## here I create my "activatable widget"
btn = Gtk.Button(label="Plz work")

## Connect it to my function
btn.connect("clicked", self.selectRoom)

# Then set it
ActionRow.set_activatable_widget(btn)

# Then I keep trying...
ActionRow.connect("activated", self.selectRoom)

# Finaly I add the ActionRow to it's final container
self.appFlowBox.append(ActionRow)

The problem: My function “selectRoom” is never called on ActionRow click in the UI.

Could someone give me some guidance ? I probably missed a core concept :sweat_smile:

If you’re trying to actually have a button in the row, add it as a suffix or a prefix first.

If you just want to make the row clickable - set activatable to true (you’re already doing that) and connect to the activated signal.

Also, rows must always be in a GtkListBox. You cannot add them to a flowbox.

Also, icon name is deprecated.

1 Like

Holy guacamole. Thank you. Just changing the parent container made everything work.oh my.

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