mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
* JS: Add textbox module * Using view_holder instead of view_dispatcher, more checks in js_textbox_show * API version sync * Rename emptyText() to clearText() * Keeping view_holder allocated for thread sefety * Js: proper comparision with 0 in js_math_sign * Js: add comments and fix condition race in textbox Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: nminaylov <nm29719@gmail.com>
31 lines
824 B
JavaScript
31 lines
824 B
JavaScript
let textbox = require("textbox");
|
|
|
|
// You should set config before adding text
|
|
// Focus (start / end), Font (text / hex)
|
|
textbox.setConfig("end", "text");
|
|
|
|
// Can make sure it's cleared before showing, in case of reusing in same script
|
|
// (Closing textbox already clears the text, but maybe you added more in a loop for example)
|
|
textbox.clearText();
|
|
|
|
// Add default text
|
|
textbox.addText("Example dynamic updating textbox\n");
|
|
|
|
// Non-blocking, can keep updating text after, can close in JS or in GUI
|
|
textbox.show();
|
|
|
|
let i = 0;
|
|
while (textbox.isOpen() && i < 20) {
|
|
print("console", i++);
|
|
|
|
// Add text to textbox buffer
|
|
textbox.addText("textbox " + to_string(i) + "\n");
|
|
|
|
delay(500);
|
|
}
|
|
|
|
// If not closed by user (instead i < 20 is false above), close forcefully
|
|
if (textbox.isOpen()) {
|
|
textbox.close();
|
|
}
|