예제 #1
0
        /// <summary>Collects options and displays the menu at the pointers position.
        /// Run this on the 'root' option list only (don't call it on submenu's).</summary>
        public void display(InputPointer ip, bool instant)
        {
            // First, collect the options:
            ContextEvent ce = collectOptions(ip);

            if (instant)
            {
                // Won't actually display - just immediately run op 0:
                run();
                return;
            }

            // Even if it collected nothing, attempt to display it.
            // The event contains the position for us.

            // Get the widget manager:
            Widgets.Manager widgets = (ce.contextDocument as HtmlDocument).widgets;

            // Open a widget (closing an existing one):
            widget = widgets.get(ce.template, null);

            if (widget != null)
            {
                widget.close();
            }

            widget = widgets.open(ce.template, null, buildGlobals(ce));
        }
예제 #2
0
        /// <summary>Collects options from the given gameobject (or any parent in the hierarchy).</summary>
        public ContextEvent collectOptions(GameObject go)
        {
            triggerGameObject = go;

            if (go == null)
            {
                return(null);
            }

            // Create a context event:
            ContextEvent ce = createEvent();

            // Locate it at the gameobject:
            Vector2 pos = rootScreenLocation;

            ce.clientX = pos.x;
            ce.clientY = pos.y;

            trigger = PowerUI.Input.ResolveTarget(go);

            if (trigger != null)
            {
                // Great - dispatch to it (which can change the coords if it wants):
                trigger.dispatchEvent(ce);
            }

            return(ce);
        }
예제 #3
0
        /// <summary>Creates a context menu event. Used during the option collect process.</summary>
        public ContextEvent createEvent(string name)
        {
            ContextEvent ce = new ContextEvent(name, null);

            ce.SetTrusted();
            ce.SetModifiers();
            ce.list = this;
            return(ce);
        }
예제 #4
0
        /// <summary>Creates the set of globals to pass through to a standard widget.
        /// Note that the only required value is 'options' (which is set to this list).
        /// Others are 'x' and 'y' - pixel values which originate from the ContextEvent's clientX/Y.</summary>
        public Dictionary <string, object> buildGlobals(ContextEvent ce)
        {
            // Create:
            Dictionary <string, object> set = new Dictionary <string, object>();

            // Add options:
            set["options"] = this;

            // top/left:
            if (ce != null)
            {
                set["x"] = ce.clientX;
                set["y"] = ce.clientY;
            }

            return(set);
        }
예제 #5
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            trigger = ip.ActiveOverTarget;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);
                return(ce);
            }

            return(ce);
        }
예제 #6
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            triggerElement = ip.ActiveOver;
            trigger        = triggerElement;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);

                triggerGameObject = null;
                return(ce);
            }

            // Collect from a 3D object:
            if (ip.LatestHitSuccess)
            {
                // Try to resolve the hit gameobject to an IEventTarget:
                triggerGameObject = ip.LatestHit.transform.gameObject;
                trigger           = ip.ResolveTarget();

                if (trigger != null)
                {
                    // Great - dispatch to it:
                    trigger.dispatchEvent(ce);
                }
            }

            return(ce);
        }
예제 #7
0
        /// <summary>Collects options from the given HTML element.</summary>
        public ContextEvent collectOptions(Element e)
        {
            trigger = e;

            if (e == null)
            {
                return(null);
            }

            // Create a context event:
            ContextEvent ce = createEvent();

            // Locate it at the element:
            Vector2 pos = rootScreenLocation;

            ce.clientX = pos.x;
            ce.clientY = pos.y;

            // Collect:
            e.dispatchEvent(ce);

            return(ce);
        }