Ejemplo n.º 1
0
        static void AttachEvent(string eventName, object domElementRef, HtmlEventProxy newProxy, Action <object> originalEventHandler)
        {
#if !BUILDINGDOCUMENTATION
            if (domElementRef is INTERNAL_HtmlDomElementReference)
            {
                Interop.ExecuteJavaScriptAsync(@"document.addEventListenerSafe($0, $1, $2)", ((INTERNAL_HtmlDomElementReference)domElementRef).UniqueIdentifier, eventName, (Action <object>)newProxy.OnEvent);
            }
            else
            {
                Interop.ExecuteJavaScriptAsync(@"document.addEventListenerSafe($0, $1, $2)", domElementRef, eventName, (Action <object>)newProxy.OnEvent);
            }

            /*
             * DOMEventType eventType;
             *
             * // Listen to the event:
             * if (TryConvertStringToDOMEventType(eventName, out eventType))
             * {
             *  // Get the DOMDocument (a DotNetBrowser object) from the Simulator:
             *  DOMDocument document = INTERNAL_Simulator.DOMDocument;
             *
             *  // Get the domElement from the id:
             *  var domElement = document.getElementByIdSafe(((INTERNAL_HtmlDomElementReference)(domElementRef)).UniqueIdentifier);
             *
             *  // Add the listener:
             *  domElement.AddEventListener(eventType, newProxy.OnEvent, false); //todo: replace "false"?
             * }
             */
#endif
        }
Ejemplo n.º 2
0
        internal static void DetachEvent(string eventName, object domElementRef, HtmlEventProxy proxy, Action <object> originalEventHandler)
        {
#if !BUILDINGDOCUMENTATION
            Interop.ExecuteJavaScriptAsync(@"document.removeEventListenerSafe($0, $1, $2)", domElementRef, eventName, (Action <object>)proxy.OnEvent);

            /*
             * DOMEventType eventType;
             *
             * //add the event to the domElement
             * if (TryConvertStringToDOMEventType(eventName, out eventType))
             * {
             *  // Get the DOMDocument (a DotNetBrowser object) from the Simulator:
             *  DOMDocument document = INTERNAL_Simulator.DOMDocument;
             *
             *  // Get the domElement from the id:
             *  var domElement = document.getElementByIdSafe(((INTERNAL_HtmlDomElementReference)(domElementRef)).UniqueIdentifier);
             *
             *  // Remove the listener:
             *  if (domElement != null) //todo: this line was added when we moved from Awesomium to DotNetBrowser because otherwise a NullReferenceException occurred. However, it is strange that thre was no NullReferenceException with Awesomium. We should investigate to understand why, because it may be a sign of a change somewhere that has broken something.
             *  {
             *      domElement.RemoveEventListener(eventType, proxy.OnEvent, false); //todo: replace "false"?
             *  }
             * }
             */
#endif
        }
Ejemplo n.º 3
0
        public static HtmlEventProxy AttachToDomEvents(string eventName, object domElementRef, Action <object> eventHandlerWithJsEventArg)
        {
            HtmlEventProxy newProxy = new HtmlEventProxy(eventName, domElementRef, eventHandlerWithJsEventArg);

            AttachEvent(eventName, domElementRef, newProxy, eventHandlerWithJsEventArg);
            return(newProxy);
        }