Hi. I am following some examples from this code and I cant quite figure out how to trigger a function when clicking a menu item.
I have a menu something like:
const myMenu = new pcui.Menu({
items: [
{ text: "First Menu Item"},
{ text: "Second Menu Item" }
]
});
editor.call('layout.viewport').append(myMenu.dom);
The menu appears fine but when I click an item it just results in an error:
myMenu.items.forEach(item => {
item.on('click', () => {
console.log('Clicked :', item.text);
});
});
Anyone have an example of a menu where items (or are they menuItems??) get clicked? Any guidance much appreciated.
Thanks