Skip to content

Commit

Permalink
Add index of the source iframe to the broadcast message
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Dec 7, 2023
1 parent dc36196 commit 45d57a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions pxtsim/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace pxsim {
export interface SimulatorBroadcastMessage extends SimulatorMessage {
broadcast: boolean;
toParentIFrameOnly?: boolean;
srcFrameIndex?: number;
}

export interface SimulatorControlMessage extends SimulatorBroadcastMessage {
Expand Down
2 changes: 2 additions & 0 deletions pxtsim/simdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 45d57a7

Please sign in to comment.