lxn / walk

A Windows GUI toolkit for the Go Programming Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] How to know which action are being trigger in EventHandler

qng95 opened this issue · comments

Hello pals,

I'm trying to create a tray icon following this example https://github.com/lxn/walk/tree/master/examples/notifyicon

The menu items inside could be dynamically created on the fly base on data that it queries from the server.
Then actions are created base on that data, and event handlers for those actions should result in different method calls depends on the text value of that action.

items = GetItemsFromAPI()
for _, item := range items {
    action := walk.NewAction()
    action.SetText(item)
    action.Triggered().Attach(func() {
        // this event handler doesn't known any information about it owner action. So it should not determine which method it should call
    })
    provisionerMenu.Actions().Add(action)
}

Is there a way to let's EventHandler know about its owner Actions?

Thank you very much 👍

Cheers