Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] Implementing IID_IDispatch from within Eclipse


The first addEventListener method works for the OleClientSite automation object (IWebBrowser in the IE case).  But, like Lynn, I need to listen to events deeper in the IE DOM: a click on a row, mouse entering a row item, a drag of an image, and the like.  

I saw that you added that second addEventListener() and got a recent SWT build to use it. I could not get it to work.  

Suppose I need to listen to onclick on an element in the IE DOM, let's say a click in the IHTMLDocument.  Given an IHTMLDocument2 OleAutomation, and a dispatch ID for onclick:

myOleBrowser.addEventListener(HTMLDoc2Automation, onClickId, myListener);

does not seem to result in a call back to myListener (what am I missing?).

In contrast, Lynn's recipe for creating an IDispatch object and using

HTMLDoc2Automation.setProperty(onClickId, myIDispatchVariant);

looked more promising.  Even with a skeleton IDispatch implementation the IDispatch Invoke() gets called on clicks in the embedded document. That's why I started on the IDispatch route.

But I have a more fundamental reason for wanting an IDispatch object. I am trying to create an Workbench Perspective with a number of Views. Some views will be standard JFace Viewers. Others may be complex OleWebBrowser Views, full of DHTML. I'm looking for a convenient way to call from elements of the Browser Control Site's DOM out to external Java code. Something like what you get with an OBJECT tag in HTML, but without the fuss of building a COM Server.

Again, I would value any advice you can offer.

______________________________________________________________________________________


I have a question about why you are creating these IDispatch objects.  You say " I don't need to attach an IDispatch object to every event I am interested in if I can embed a single global callback object for all events."

There is API on OleControlSite which is:


public
void addEventListener(int eventID, OleListener listener)
public
void addEventListener(OleAutomation automation, int eventID, OleListener listener)

These two methods use the IDispatch object implemented in OleEventSink ( a common definition of IDispatch that is used for all events)  and give notification when the events change.  Is this API not sufficient for what you are doing?  Do you really need to be implementing IDispatch at all?



"Seymour Kellerman/Cambridge/IBM" <seymour_kellerman@xxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

17/04/2002 02:58 PM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx

        cc:        lmonson@xxxxxxxxxxxx

        Subject:        RE: [platform-swt-dev] Implementing IID_IDispatch from within Eclipse






Thank you for your continuing guidance, Veronika and Lynn, as in
http://dev.eclipse.org/mhonarc/lists/platform-swt-dev/msg00741.html

With the information you've provided, I can try to create an IDispatchImpl class...


Two further questions:


1.What is the commitment to support creating an IDispatch object in SWT Release 2?
This feature would add much to SWT's Ole support. Currently, any implementation I can build must be based on SWT internal classes.  Do you plan to offer any more public support in R2?


2. How about passing an IDispatch object into the IWebBrowser DOM by executing a _javascript_?

We are looking for the ability to install DHTML event handlers into an IE DOM that call back to Java code.  Why not pass an Eclipse IDispatch object that includes my favorite callback methods into the DOM via _javascript_ (see below)?   I don't need to attach an IDispatch object to every event I am interested in if I can embed a single global callback object for all events. Is this a viable strategy?



Execute a named _javascript_ in an IE DOM as follows:

From IWebBrowser get the IHTMLDocument automation with the Document() property.

From IHTMLDocument get the Script Engine automation with the Script() property.

Use  ScriptEngineOleAutomation.getIDsOfNames(new String[]{"myfunctionName"})
to get a dispatch ID for a function you know is on the page.
Use ScriptEngineOleAutomation.invoke(functionID, args) to invoke the function, passing an IDispatch Variant to the page DOM.



Back to the top