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);
            }
        }
Esempio n. 2
0
        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);
Esempio n. 4
0
 protected override void Init()
 {
     base.Init();
     this.menu = null;
 }