For .NET maui;
I have a MenuFlyout, have two context items added to it. And I'm attaching this right click context menu to two seperate labels:
Label label1=new Label(){Text="MyLabel1"};
Label label2=new Label(){Text="MyLabel2"};
MenuFlyout menuElements = new MenuFlyout();
MenuFlyoutItem item1 = new MenuFlyoutItem() { Text = "menu1" };
MenuFlyoutItem item2 = new MenuFlyoutItem() { Text = "menu2" };
item1.Clicked+=async(s,e)=>
{
//menu1 click fires here when clicking both labels, but i can't catch which label is clicked
};
menuElements.Add(item1);
menuElements.Add(item2);
FlyoutBase.SetContextFlyout(label1, menuElements);
FlyoutBase.SetContextFlyout(label2, menuElements);
Popup menu shows for each label and click event fires for menu items. Is it possible to catch the element (label that is right clicked) that shows the popup menu in the Clicked event?
--
EDIT: for windows (winui) it is possible to create a handler for right click, and set which label is right clicked silently before popup is shown. so i can use that in Clicked event. But I need this for macCatalyst. I couldn't find a workaround for handling right click in macCatalyst
#if MACCATALYST
handler.PlatformView.UserInteractionEnabled = true;
UITapGestureRecognizer gesture=new UITapGestureRecognizer(MACC_HandleRightClick);
gesture.ButtonMaskRequired= UIEventButtonMask.Secondary;
handler.PlatformView.AddGestureRecognizer(gesture);
//MAC_HandleRightClick isn't called on right click
#endif
--
Regards