Menu item clicks

  • 2 Replies
Menu item clicks
« on: 14 September 2020, 16:15:17 »
Hi There

Just started playing around with 0.9 and as others have mentioned there is no connect. I realise it is still a work in progress but it's looking great so far. I see for menu items there is OnMenuItemClick. I can give it a lambda function OK but struggling to work out how to reference a specific item. I did see in the code the connectMenuItem and can use something like this that works fine-
Code: (cpp) [Select]
menu->connectMenuItem({ "File","Exit" }, [&](){ ExitClicked(); });
Is is OK to use this rather than OnMenuItemClick as that function doesn't seem to take the { "File","Exit" } as an option for an item.

Regards Peter



  • *****
  • 1620
    • View Profile
    • Texus's Blog
Re: Menu item clicks
« Reply #1 on: 14 September 2020, 17:03:17 »
The connectMenuItem function is still the correct way to do this (and it just calls onMenuItemClick internally). Although it is a bit weird that all other connects are handled by onXxx, it has always been a bit of a weird function (since every other signal used the normal "connect" function while here you needed "connectMenuItem"). I don't immediately see a better way to do it, so connectMenuItem is likely going to remain unchanged.

Re: Menu item clicks
« Reply #2 on: 15 September 2020, 03:27:25 »
Thanks Texus. Thought that might be the case. Still getting my head around the code, but it did seem different.

Cheers Peter