zawadz88 / MaterialPopupMenu

Shows Material popup menus grouped in sections & more
Apache License 2.0
646 stars 57 forks source link

Make sections in MaterialPopupMenu public #55

Open SasLuca opened 5 years ago

SasLuca commented 5 years ago

I want to be able to modify the UI elements in the popup menu when the user clicks on them, however I can't do this right now because they private.

I think it would be better if they were public so that we could modify them or offer users a different way to modify them.

zawadz88 commented 5 years ago

Hi @SasLuca, I'm not sure if I understand this. Would like to be able to update the popup menu while it's still displayed without closing it? If so, how would it look like? What kind of modification do you have in mind?

SasLuca commented 5 years ago

Yeah, I would like to update the popup menu while it's still displaying without closing it. I now realise that is a bit harder to do.

Maybe there could be a refresh() function for MaterialPopupMenu that you would call within a callback like such:

var ct = 0

val popupMenu = popupMenu()
{
    section()
    {
        item()
        {
            label = "Counter: $ct"
            callback =
            {
                ct++
                label = "Counter: $ct"
                popupMenu.refresh()
            }
        }
    }
}
zawadz88 commented 5 years ago

If you would like to refresh an individual label when clicked you could use a custom item, get a reference to a textview in that View and update it accordingly when clicked. Or do you have something else in mind?