public void DisplayMenu(EventBase triggerEvent, IEventHandler target) { ContextualMenu contextualMenu = new ContextualMenu(); bool flag; using (ContextualMenuPopulateEvent pooled = ContextualMenuPopulateEvent.GetPooled(triggerEvent, contextualMenu, target)) { UIElementsUtility.eventDispatcher.DispatchEvent(pooled, null); flag = !pooled.isDefaultPrevented; } if (flag) { contextualMenu.PrepareForDisplay(triggerEvent); this.DoDisplayMenu(contextualMenu, triggerEvent); } }
public static ContextualMenuPopulateEvent GetPooled(EventBase triggerEvent, ContextualMenu menu, IEventHandler target) { ContextualMenuPopulateEvent pooled = EventBase <ContextualMenuPopulateEvent> .GetPooled(); if (triggerEvent != null) { IMouseEvent mouseEvent = triggerEvent as IMouseEvent; if (mouseEvent != null) { pooled.modifiers = mouseEvent.modifiers; pooled.mousePosition = mouseEvent.mousePosition; pooled.localMousePosition = mouseEvent.mousePosition; pooled.mouseDelta = mouseEvent.mouseDelta; pooled.button = mouseEvent.button; pooled.clickCount = mouseEvent.clickCount; } pooled.target = target; pooled.menu = menu; } return(pooled); }
protected abstract void DoDisplayMenu(ContextualMenu menu, EventBase triggerEvent);
protected override void Init() { base.Init(); this.menu = null; }