Using DOM in microStudio
Hello everyone, tell me, has anyone already tried using DOM in microStudio? How is this done?
Hello everyone, tell me, has anyone already tried using DOM in microStudio? How is this done?
In MicroScript
you generally can't use DOM elements from the browser, even objects like screen are an interface to the actual element in JavaScript that has access to the DOM
.
This is to make the whole MicroScript user-friendly and portable (different browsers have different compliance with the official HTML/javascript specification).
However, there is a hack that allows you to manipulate elements below MicroScript (MicroScript is the highest level, below that is the JavaScript code responsible for interpreting MicroScript, below that is pure JavaScript).
In MicroScript code you use a call to the JavaScript code like this
get_canvas = function()
system.javascript("""
global.canvas = window.player.runtime.screen.canvas
global.context = global.canvas.getContext("2d")
""")
end
You can also combine MicroScript and JavaScript code. To do this
file >> name_abcdef
// javscript
global.window = window;
file >> main
init = function()
print( window )
end
Now you have access to the window variable, and if you can create an HTML element from the JavaScript code, you have access to the DOM.
Yeah, it's going to be hard...
Thanks, I'll experiment with it.
I just want to make a number of user interface elements that are either difficult or impossible to do with what is available now, for example, typing text like in a browser
By the way, microScript is the least interesting to me at this stage, I want to do it at least with the help of JS
Are there any other options to make a normal user interface?