diff --git a/pxtsim/embed.ts b/pxtsim/embed.ts index 0f3ecf99a416..59ed1873a763 100644 --- a/pxtsim/embed.ts +++ b/pxtsim/embed.ts @@ -83,6 +83,7 @@ namespace pxsim { export interface SimulatorBroadcastMessage extends SimulatorMessage { broadcast: boolean; toParentIFrameOnly?: boolean; + srcFrameIndex?: number; } export interface SimulatorControlMessage extends SimulatorBroadcastMessage { diff --git a/pxtsim/simdriver.ts b/pxtsim/simdriver.ts index 525189be2a48..66bd18a54aee 100644 --- a/pxtsim/simdriver.ts +++ b/pxtsim/simdriver.ts @@ -319,6 +319,8 @@ namespace pxsim { const broadcastmsg = msg as pxsim.SimulatorBroadcastMessage; if (source && broadcastmsg?.broadcast) { + // include index of the source iframe + broadcastmsg.srcFrameIndex = frames.findIndex((item) => item.contentWindow === source) // if the editor is hosted in a multi-editor setting // don't start extra frames const single = !!this._currentRuntime?.single;