예제 #1
0
        /// <summary>
        /// This is used to mark the IE event object so we do not do the Closure pass
        /// twice for a bubbling event.
        /// </summary>
        /// <param name="e"></param>
        private static void markIeEvent_(Bridge.Html5.Event e)
        {
            // Only the keyCode and the returnValue can be changed. We use keyCode for
            // non keyboard events.
            // event.returnValue is a bit more tricky. It is undefined by default. A
            // boolean false prevents the default action. In a window.onbeforeunload and
            // the returnValue is non undefined it will be alerted. However, we will only
            // modify the returnValue for keyboard events. We can get a problem if non
            // closure events sets the keyCode or the returnValue

            var useReturnValue = false;

            if (e.KeyCode == 0)
            {
                // We cannot change the keyCode in case that srcElement is input[type=file].
                // We could test that that is the case but that would allocate 3 objects.
                // If we use try/catch we will only allocate extra objects in the case of a
                // failure.
                /** @preserveTry */
                try {
                    e.KeyCode = -1;
                    return;
                }
                catch (Exception) {
                    useReturnValue = true;
                }
            }

            if (useReturnValue ||
                ((bool?)e["returnValue"]) != true)
            {
                e["returnValue"] = true;
            }
        }
예제 #2
0
 public KeyEvent(int keyCode, int charCode, bool repeat, Bridge.Html5.Event browserEvent)
     : base(browserEvent)
 {
     this.keyCode  = keyCode;
     this.charCode = charCode;
     this.repeat   = repeat;
 }
예제 #3
0
 /// <summary>
 /// Accepts a browser event object and creates a patched, cross browser event
 /// object.
 /// The content of this object will not be initialized if no event object is
 /// provided. If this is the case, init() needs to be invoked separately.
 /// </summary>
 /// <param name="opt_e">Browser event object.</param>
 /// <param name="opt_currentTarget">Current target for event.</param>
 public BrowserEvent(Bridge.Html5.Event opt_e, Bridge.Html5.EventTarget opt_currentTarget = null)
     : base(opt_e)
 {
     if (opt_e != null)
     {
         this.init(opt_e, opt_currentTarget);
     }
 }
예제 #4
0
 private static void InputKeyPress(Event e)
 {
     // We added the listener to EventType.KeyPress so it should be a KeyboardEvent
     if (e.IsKeyboardEvent() && e.As<KeyboardEvent>().KeyCode == 13)
     {
         Save();
     }
 }
예제 #5
0
 /// <summary>
 /// This is used to check if an IE event has already been handled by the Closure
 /// system so we do not do the Closure pass twice for a bubbling event.
 /// </summary>
 /// <param name="e">The IE browser event.</param>
 /// <returns>True if the event object has been marked.</returns>
 private static bool isMarkedIeEvent_(Bridge.Html5.Event e)
 {
     return(e.KeyCode < 0 || ((bool?)e["returnValue"]) != null);
 }
예제 #6
0
파일: jQueryApp.cs 프로젝트: phaethom/Demos
        public static void UpdateButton_Click(Event e)
        {
            jQuery.Ajax(
                new AjaxOptions()
                {
                    Url = Config.GET_SERVER_TIME_URL,
                    Cache = false,
                    Success = delegate(object data, string textStatus, jqXHR request)
                    {
                        var val = JSON.Parse((string)data).As<string>();
                        var dateTime = DateTime.ParseExact(val, "yyyy-MM-ddTHH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);

                        jQuery.Select("#dateTimeInput").Val(dateTime.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                }
             );
        }
        void onDocumentMouseUp(Event arg)
        {
            if (!IsActive) return;

            MouseEvent e = arg.As<MouseEvent>();

            e.PreventDefault();

            controls.enabled = true;

            if (intersected != null)
            {
                plane.position.copy(intersected.position);
                selected = null;
            }

            Container.Style.Cursor = Cursor.Auto;
        }
        void onDocumentMouseDown(Event arg)
        {
            if (!IsActive) return;

            MouseEvent e = arg.As<MouseEvent>();
            e.PreventDefault();

            THREE.Vector3 vector = new THREE.Vector3(mouse.x, mouse.y, 0.5).unproject(camera);

            var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());

            THREE.Intersection[] intersects = raycaster.intersectObjects(allObjects);

            if (intersects.Length > 0 )
            {
                THREE.Intersection interSec = intersects[0];
                THREE.Mesh m = interSec.Object as THREE.Mesh;

                if (m != null)
                {
                    controls.enabled = false;
                    selected = m;
                    intersects = raycaster.intersectObject(plane);
                    offset.copy(interSec.point).sub(plane.position);
                    Container.Style.Cursor = Cursor.Move;
                }
            }
        }
예제 #9
0
파일: App.cs 프로젝트: txdv/Live
        /// <summary>
        /// Adjust editor size
        /// </summary>
        protected static void SetEditorSize(Event e = null)
        {
            // Set editor height
            int mastheadHeight = jQuery.Select("#masthead").OuterHeight();
            int titleHeight = jQuery.Select("#title").OuterHeight();
            int editorHeaderHeight = jQuery.Select(".code-description").OuterHeight();
            int sitefooterHeight = jQuery.Select(".site-footer").OuterHeight();
            int padding = 15;

            int editorHeight = Window.InnerHeight - (mastheadHeight + titleHeight  + editorHeaderHeight + sitefooterHeight  + padding);
            jQuery.Select(".ace_editor").Css("height", editorHeight);
        }
예제 #10
0
파일: App.cs 프로젝트: txdv/Live
        protected static void LoadExample(Event evt)
        {
            // Click event handler attached to #examples > li > a
            evt.PreventDefault();
            App.LoadFromGist(jQuery.This.Attr("title"), jQuery.This.Attr("href"));

            // Clear active for all #examples > li
            jQuery.Select("#examples > li").RemoveClass("active");

            // Mark currently selected li as active
            jQuery.This.Parent().AddClass("active");

            // Update editor title with selected file name
            jQuery.Select("#filename").Html(jQuery.This.Text());
        }
예제 #11
0
 protected virtual void onWindowResize(Event arg)
 {
     UpdateRenderSize();
 }
예제 #12
0
            /// <summary>
            /// Accepts a browser event object and creates a patched, cross browser event
            /// object.
            /// </summary>
            /// <param name="e">Browser event object.</param>
            /// <param name="opt_currentTarget">Current target for event.</param>
            public void init(Bridge.Html5.Event e, Bridge.Html5.EventTarget opt_currentTarget)
            {
                var type = this.type = e.Type;

                /**
                 * On touch devices use the first "changed touch" as the relevant touch.
                 * @type {Touch}
                 */
                var relevantTouch = e.ChangedTouches != null ? e.ChangedTouches[0] : null;

                // TODO(nicksantos): Change this.target to type EventTarget.
                this.target = (e.Target) ?? e.SrcElement;

                // TODO(nicksantos): Change this.currentTarget to type EventTarget.
                this.currentTarget = opt_currentTarget;

                var relatedTarget = (Node)e.RelatedTarget;

                if (relatedTarget != null)
                {
                    // There's a bug in FireFox where sometimes, relatedTarget will be a
                    // chrome element, and accessing any property of it will get a permission
                    // denied exception. See:
                    // https://bugzilla.mozilla.org/show_bug.cgi?id=497780
                    if (goog.userAgent.GECKO)
                    {
                        if (!goog.reflect.canAccessProperty(relatedTarget, "nodeName"))
                        {
                            relatedTarget = null;
                        }
                    }
                    // TODO(arv): Use goog.events.EventType when it has been refactored into its
                    // own file.
                }
                else if (type == goog.events.EventType.MOUSEOVER)
                {
                    relatedTarget = e.FromElement;
                }
                else if (type == goog.events.EventType.MOUSEOUT)
                {
                    relatedTarget = e.ToElement;
                }

                this.relatedTarget = relatedTarget;

                if (relevantTouch != null)
                {
                    this.clientX = Script.IsDefined(relevantTouch, "clientX") ?
                                   (int)relevantTouch.ClientX :
                                   (int)relevantTouch.PageX;
                    this.clientY = Script.IsDefined(relevantTouch, "clientY") ?
                                   (int)relevantTouch.ClientY :
                                   (int)relevantTouch.PageY;
                    this.screenX = relevantTouch.ScreenX;
                    this.screenY = relevantTouch.ScreenY;
                }
                else
                {
                    // Webkit emits a lame warning whenever layerX/layerY is accessed.
                    // http://code.google.com/p/chromium/issues/detail?id=101733
                    this.offsetX = (goog.userAgent.WEBKIT || e.IsDefined("offsetX")) ?
                                   (int)e.OffsetX :
                                   (int)e.LayerX;
                    this.offsetY = (goog.userAgent.WEBKIT || e.IsDefined("offsetY")) ?
                                   (int)e.OffsetY :
                                   (int)e.LayerY;
                    this.clientX = e.IsDefined("clientX") ? (int)e.ClientX : (int)e.PageX;
                    this.clientY = e.IsDefined("clientY") ? (int)e.ClientY : (int)e.PageY;
                    this.screenX = e.IsDefined("screenX") ? (int)e.ScreenX : 0;
                    this.screenY = e.IsDefined("screenY") ? (int)e.ScreenY : 0;
                }

                this.button = e.Button;

                this.keyCode             = e.IsDefined("keyCode") ? e.KeyCode : 0;
                this.charCode            = e.IsDefined("charCode") ? e.CharCode : (type == "keypress" ? e.KeyCode : 0);
                this.ctrlKey             = e.CtrlKey;
                this.altKey              = e.AltKey;
                this.shiftKey            = e.ShiftKey;
                this.metaKey             = e.MetaKey;
                this.platformModifierKey = goog.userAgent.MAC ? e.MetaKey : e.CtrlKey;
                this.state  = e.State;
                this.event_ = e;
                if (e.IsDefined("defaultPrevented"))
                {
                    this.preventDefault();
                }
            }
예제 #13
0
 /// <summary>
 /// Dispatches the specified event to the current element.
 /// To create an event object use the createEvent method in Firefox, Opera, Google Chrome, Safari and Internet Explorer from version 9. After the new event is created, initialize it first (for details, see the page for the createEvent method). When the event is initialized, it is ready for dispatching.
 /// </summary>
 /// <param name="e">Required. Reference to an event object to be dispatched.</param>
 /// <returns>Boolean that indicates whether the default action of the event was not canceled.</returns>
 public virtual extern bool DispatchEvent(Event e);
예제 #14
0
파일: App.cs 프로젝트: Zaid-Ajaj/Demos
 public static void UpdateButton_Click(Event e)
 {
     App.GetForecast();
 }
예제 #15
0
파일: App.cs 프로젝트: txdv/Live
 protected static void HookRunEvent(Event evt)
 {
     evt.PreventDefault();
     Window.Open("run.html?h=" + jQuery.Select("#hash").Text());
 }
예제 #16
0
파일: App.cs 프로젝트: txdv/Live
        protected static void HookShareEvent(Event evt)
        {
            evt.PreventDefault();

            App.CreatePermaLink(App.CsEditor.getValue());
        }
        public void SwitchCase(Event arg)
        {
            KeyboardEvent e = arg.As<KeyboardEvent>();

            switch (e.KeyCode)
            {
                case 81: // Q
                    controls.setSpace(controls.space == "local" ? "world" : "local");
                    break;
                case 87: // W
                    controls.setMode("translate");
                    break;
                case 69: // E
                    controls.setMode("rotate");
                    break;
                case 82: // R
                    controls.setMode("scale");
                    break;
                case 187:
                case 107: // +,=,num+
                    controls.setSize(controls.size + 0.1);
                    break;
                case 189:
                case 10: // -,_,num-
                    controls.setSize(Math.Max(controls.size - 0.1, 0.1));
                    break;
            }
        }
예제 #18
0
파일: App.cs 프로젝트: txdv/Live
 protected static void OffCanvasMenu(Event e)
 {
     e.PreventDefault();
     jQuery.Select("#sidebar-offcanvas, .main-wrapper").ToggleClass("active");
     jQuery.Select("body").ToggleClass("offcanvas-open");
 }
예제 #19
0
파일: Cube.cs 프로젝트: phaethom/Demos
 public void HandleKeyDown(Event e)
 {
     this.currentlyPressedKeys[e.As<KeyboardEvent>().KeyCode] = true;
 }
예제 #20
0
파일: Html5App.cs 프로젝트: phaethom/Demos
        public static void UpdateButton_Click(Event e)
        {
            var request = new XMLHttpRequest();

            Action<Event> onLoad = delegate
            {
                var val = JSON.Parse(request.ResponseText).As<string>();
                var dateTime = DateTime.Parse(val);

                Document.GetElementById<InputElement>("dateTimeInput").Value = dateTime.ToString("yyyy-MM-dd hh:mm:ss");
            };

            request.OnLoad = onLoad;
            request.Open("GET", Config.GET_SERVER_TIME_URL + "?" + DateTime.Now.GetTime(), true);
            request.Send();
        }
예제 #21
0
파일: Cube.cs 프로젝트: phaethom/Demos
 public void HandleKeyUp(Event e)
 {
     this.currentlyPressedKeys[e.As<KeyboardEvent>().KeyCode] = false;
 }
        void onDocumentMouseMove(Event arg)
        {
            if (!IsActive) return;

            MouseEvent e = arg.As<MouseEvent>();
            e.PreventDefault();

            SetMousePos(e);
            raycaster.setFromCamera(mouse, camera);

            THREE.Intersection[] intersects;

            if (selected != null )
            {
                intersects = raycaster.intersectObject(plane);
                selected.position.copy(intersects[0].point.sub(offset));
                return;

            }

            intersects = raycaster.intersectObjects(allObjects);

            if (intersects.Length > 0)
            {
                THREE.Intersection i = intersects[0];
                THREE.Mesh m = i.Object as THREE.Mesh;

                if (m!=null && m!= intersected)
                {
                    intersected = m;
                    plane.position.copy(intersected.position);
                    plane.lookAt(camera.position);

                }
                Container.Style.Cursor = Cursor.Pointer;
            }
            else
            {
                intersected = null;
                Container.Style.Cursor = Cursor.Auto;
            }
        }
예제 #23
0
 /// <summary>
 /// Dispatches the specified event to the current element.
 /// To create an event object use the createEvent method in Firefox, Opera, Google Chrome, Safari and Internet Explorer from version 9. After the new event is created, initialize it first (for details, see the page for the createEvent method). When the event is initialized, it is ready for dispatching.
 /// </summary>
 /// <param name="e">Required. Reference to an event object to be dispatched.</param>
 /// <returns>Boolean that indicates whether the default action of the event was not canceled.</returns>
 public virtual bool DispatchEvent(Event e)
 {
     return false;
 }
예제 #24
0
 public Event(Bridge.Html5.Event e, object opt_target = null)
 {
     this.type   = e.Type;
     this.target = opt_target;
 }
예제 #25
0
        /// <summary>
        /// Handles an event and dispatches it to the correct listeners. This
        /// function is a proxy for the real listener the user specified.
        /// </summary>
        /// <param name="listener">The listener object.</param>
        /// <param name="opt_evt">Optional event object that gets passed in via the
        /// native event handlers.</param>
        /// <returns>Result of the event handler.</returns>
        private static bool handleBrowserEvent_(Bridge.Html5.EventTarget _this, goog.events.Listener listener, Bridge.Html5.Event opt_evt = null)
        {
            if (listener.removed)
            {
                return(true);
            }

            // Synthesize event propagation if the browser does not support W3C
            // event model.
            if (!goog.events.BrowserFeature.HAS_W3C_EVENT_SUPPORT)
            {
                var ieEvent = opt_evt ??
                              ((Bridge.Html5.Event)goog.le.getObjectByName("window.event"));
                var evt = new goog.events.BrowserEvent(ieEvent, _this);
                /** @type {boolean} */
                var retval = true;

                if (goog.events.CAPTURE_SIMULATION_MODE ==
                    goog.events.CaptureSimulationMode.ON)
                {
                    // If we have not marked this event yet, we should perform capture
                    // simulation.
                    if (!goog.events.isMarkedIeEvent_(ieEvent))
                    {
                        goog.events.markIeEvent_(ieEvent);

                        var ancestors = new JsArray <Node>();
                        for (var parent = (Node)evt.currentTarget; parent != null;
                             parent = parent.ParentNode)
                        {
                            ancestors.Push(parent);
                        }

                        // Fire capture listeners.
                        var type = listener.type;
                        for (var i = ancestors.Length - 1; !evt.propagationStopped_ && i >= 0;
                             i--)
                        {
                            evt.currentTarget = ancestors[i];
                            var result =
                                goog.events.fireListeners_(ancestors[i], type, true, evt);
                            retval = retval && result != null;
                        }

                        // Fire bubble listeners.
                        //
                        // We can technically rely on IE to perform bubble event
                        // propagation. However, it turns out that IE fires events in
                        // opposite order of attachEvent registration, which broke
                        // some code and tests that rely on the order. (While W3C DOM
                        // Level 2 Events TR leaves the event ordering unspecified,
                        // modern browsers and W3C DOM Level 3 Events Working Draft
                        // actually specify the order as the registration order.)
                        for (var i = 0; !evt.propagationStopped_ && i < ancestors.Length; i++)
                        {
                            evt.currentTarget = ancestors[i];
                            var result =
                                goog.events.fireListeners_(ancestors[i], type, false, evt);
                            retval = retval && result != null;
                        }
                    }
                }
                else
                {
                    retval = goog.events.fireListener(listener, evt);
                }
                return(retval);
            }

            // Otherwise, simply fire the listener.
            return(goog.events.fireListener(
                       listener, new goog.events.BrowserEvent(opt_evt, _this)));
        }