Created
December 23, 2022 12:15
-
-
Save bjoerntx/e92703449e457b5327b1046c722f2c87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function replaceSubTextParts(startsWithText) { | |
TXTextControl.subTextParts.getCount(async function(count) { | |
for (var i = count - 1; i >= 0; i--) { | |
await replaceText(i, startsWithText); | |
} | |
}) | |
} | |
function replaceText(i, startsWithText) { | |
return new Promise(resolve => { | |
TXTextControl.subTextParts.elementAt(i, function(stp) { | |
stp.getName(function(name) { | |
if (name.startsWith(startsWithText)) { | |
stp.getStart(function(start) { | |
stp.getLength(function(length) { | |
TXTextControl.select(start - 1, length - 1, function() { | |
TXTextControl.selection.setText("Replaced SubTextPart Text"); | |
TXTextControl.focus(); | |
TXTextControl.clear(); | |
resolve(true); | |
}) | |
}) | |
}) | |
} else resolve(false); | |
}) | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment