Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Window.PostMessage (For Tim)
Mon, Jul 30 2018 10:45 AMPermanent Link

Mark Brooks

Slikware

Avatar

I have a scenario where I have a "parent" EWB app that contains a TBrowser instance. The parent EWB app updates the TBrowser URL to load one of several "child" EWB apps. I'm using this technique in order to modularise my codebase for a large project and it works really well (so far).

As part of the technique I need to communicate from each of the child EWB apps back to the parent EWB app. I'm using Window,PostMessage to do this and, again, it seems to work really well.

However, I have needed to add the PostMessage method into TWindow within WebDOM like this:

        procedure postMessage(const message: String; const targetOrigin: String);

Firstly is this definition correct? Secondly, is there a reason that I should be aware of regarding why it was omitted in the first place? I'm just worried that I get too far down the line and then something goes "BOOM".

Many thanks
Mark
Tue, Jul 31 2018 3:16 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Firstly is this definition correct? >>

It's close enough.  The 3rd parameter is for transferring objects, which you probably won't need to do.

<< Secondly, is there a reason that I should be aware of regarding why it was omitted in the first place?>>

IE10+, and our base browser is still IE9.

Did you also implement an event handler for the messages coming in ?

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jul 31 2018 5:44 PMPermanent Link

Mark Brooks

Slikware

Avatar

Tim Young [Elevate Software] wrote:

>> Did you also implement an event handler for the messages coming in ?

Hi Tim. Thanks for the info. Yes I have an event handler that catches events from the TBrowser-embedded EWB app up in the parent EWB-app, like this:

function TrapChildMessage(AEvent: TMessageEvent): boolean;

which I attach like this:

Window.AddEventListener('message',TrapChildMessage,False);

Out of interest, what does the boolean return value signify in TrapChildMessage?

Regards
Mark
Mon, Aug 6 2018 2:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Out of interest, what does the boolean return value signify in TrapChildMessage? >>

I assume that you mean "AddEventListener" ?  The Boolean parameter indicates whether you're defining a "capturing" event handler (True), or a "bubbling" event handler (False).  Most of the time, you want this to be False.

A "capturing" event handler is triggered as an event is first dispatched from the root element down to the target element.

A "bubbling" event handler is triggered as an event is dispatched from the target element outward to the root element.

https://stackoverflow.com/questions/4616694/what-is-event-bubbling-and-capturing

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Aug 9 2018 8:42 AMPermanent Link

Mark Brooks

Slikware

Avatar

Got it now - thanks
Image