Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting selected Index from FSPopoverListTextItem #21

Closed
mohitordex opened this issue Feb 27, 2024 · 1 comment
Closed

Not getting selected Index from FSPopoverListTextItem #21

mohitordex opened this issue Feb 27, 2024 · 1 comment

Comments

@mohitordex
Copy link

mohitordex commented Feb 27, 2024

Screenshot 2024-02-27 at 4 22 55 PM

Item.selectorHandler is giving item, but i need selected Index. As shown above image i am using stores which is a [String]. We are showing stores name in list and store name can be same so i was wondering if there's any way to get the selected Index from the selectedHandler Closure.

I have tried to set the tag property but couldn't find any object on which i can set it.

Any help will be appreciated. Thank you!

@lifution
Copy link
Owner

Try the following:

let items = stores.enumerated().map { (index, store) in
    let item = FSPopoverListTextItem()
    item.title = store
    item.selectedHandler = { item in
        guard let item = item as? FSPopoverListTextItem else {
            return
        }
        print("did select item at [\(index)]")
    }
    item.updateLayout()
    return item
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants