Remorse.popupAction - workaround for callback context?

Hi everyone,

im currently creating a small Magic the Gathering “Search App” (shameless plug).

In one of the app pages I have a GridView every GridItem has a ContextMenu to be able to delete that item. For Deletion I want to use a Remorse Popup.
The Problem now is that the Remorse-Callback runs “in remorse component scope” therefore I don’t have access to my DatabaseCompontent (id: favorites)

Is there any workaround or any way I could trigger the database deletion (aka. any function from a page component) inside the remorse popup?

Page {
    id: page

    Favorites {
        id: favorites
    }
    SilicaGridView {
        id: grid
        // ...
       
            delegate: GridItem {
            // ...

            menu: Component {
                ContextMenu {
                    MenuItem {
                        text: qsTr("Remove")
                        onClicked: {
                            Remorse.popupAction(qsTr("Remove from favorites?"), function(){
                                // favorites is undefined because this callback function is called "in remorse component scope". it works when not used inside the Remorese.popupAction callback
                                favorites.removeFavorite(cardID)
                                grid.model.remove(index)
                            })
                        }
                    }
                }
            }
        }

Nevermind you can actually just create your own page specific Remorse Object

RemorsePopup {
    id: remorse
}
// and then later
onClicked: {
    remorse.execute("remorse stuff", function(){
        // page specific components available!
    })
}
1 Like