Skip to content

Commit

Permalink
add upgrade rule for new system keyboard APIs (#6700)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll authored Feb 21, 2025
1 parent 50103e9 commit 68bf8d8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions editor/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,32 @@ namespace pxt.editor {
});
}
}

// Added the "use system keyboard" options to the ask for number and ask for string blocks
if (pxt.semver.strcmp(pkgTargetVersion || "0.0.0", "2.0.18") < 0) {
const allPromptBlocks = U.toArray(dom.querySelectorAll("block[type=gameaskforstring]"))
.concat(U.toArray(dom.querySelectorAll("shadow[type=gameaskforstring]")))
.concat(U.toArray(dom.querySelectorAll("block[type=gameaskfornumber]")))
.concat(U.toArray(dom.querySelectorAll("shadow[type=gameaskfornumber]")));

for (const block of allPromptBlocks) {
if (!getChildNode(block, "value", "name", "useSystemKeyboard")) {
const value = document.createElement("value");
value.setAttribute("name", "useSystemKeyboard");

const shadow = document.createElement("shadow");
shadow.setAttribute("type", "logic_boolean");

const field = document.createElement("field");
field.setAttribute("name", "BOOL");
field.textContent = "FALSE";

shadow.appendChild(field);
value.appendChild(shadow);
block.appendChild(value);
}
}
}
}

function swapFieldIfNotMatching(
Expand Down

0 comments on commit 68bf8d8

Please sign in to comment.