[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Javascript window.external in swt

Dear List,

 

just made some modifications to Browser.java and WebSite.java to get the _javascript_ Function window.external working.

The modification is used to get an COMObject to the GetExternal Function in WebSite.java.

Is there any possibility to get the code changes done in the associated files ?

 

Best regards

C. Stoerkel

 

For WebSite.java i added the class Variable

 

      COMObject iScriptingObject;

 

And initialized it in createCOMInterfaces to null.

 

Although the following Function has beend added

 

/* Used for setting the COMObject to be accesed by _javascript_ call window.external */

public void SetWindowForScripting(COMObject iInterface)

{

      iScriptingObject = iInterface;

}

 

And changed:

 

/* If window.external should be handled then call SetWindowForScripting for the COMObject to be exported to the browser */

int GetExternal(int ppDispatch)

{

      int sRet;

     

      if (iScriptingObject != null)

      {

            OS.MoveMemory(ppDispatch, new int[] {iScriptingObject.getAddress()}, 4);

            sRet = COM.S_OK;

      }

      else

      {

            OS.MoveMemory(ppDispatch, new int[] {0}, 4);

            sRet = COM.S_FALSE;

      }

      return sRet;

}

 

In Browser.java I added

 

/* Used for setting the COMObject to be accesed by _javascript_ call window.external */

public void SetWindowForScripting(COMObject iInterface)

{

      ((WebSite)this.site).SetWindowForScripting(iInterface);

}