Variadic final param not working in Menu function.

Issue #16 closed
Winter Laite created an issue

Non-compiling code:

MyMenu := Menu()
MyMenu.Add("Item 1", "MenuHandler")
MyMenu.Add("Item 2", "MenuHandler")
MyMenu.Add()  ; Add a separator line.

; Create another menu destined to become a submenu of the above menu.
Submenu1 := Menu()
Submenu1.Add("Item A", "MenuHandler")
Submenu1.Add("Item B", "MenuHandler")

; Create a submenu in the first menu (a right-arrow indicator). When the user selects it, the second menu is displayed.
MyMenu.Add("My Submenu", Submenu1)

MyMenu.Add()  ; Add a separator line below the submenu.
MyMenu.Add("Item 3", "MenuHandler")  ; Add another menu item beneath the submenu.

MenuHandler(Item, *) {
    MsgBox("You selected " Item)
}

#z::MyMenu.Show()  ; i.e. press the Win-Z hotkey to show the menu.

With the '*' removed from function MenuHandler, like this:

MenuHandler(Item) {
    MsgBox("You selected " Item)
}

the script hangs upon pressing the hotkey (Win-Z), although the menu partially and transparently appears. The script must then be killed manually from the tray.

Comments (4)

  1. Matt Feemster repo owner

    This included two bugs. One was that I was calling variadic functions wrong, the other was that the Show() call was not being placed on the gui thread. I’ve attempted to fix both. Please retest.

  2. Log in to comment