Closed retsyo closed 1 year ago
@retsyo Just to confirm, by using hello_world.nim
, can you compile and show the window just fine?
I am using nim in MSYS2+MINGW64 on windows 10 64 bits. I installed webui via
nimble install webui
$ nim --version Nim Compiler Version 1.9.3 [Windows: amd64] Compiled at 2023-06-16 Copyright (c) 2006-2023 by Andreas Rumpf git hash: 77beb152141f0efe4d5c93b784e42f973ba46551 active boot switches: -d:release
I can compile when I try and run
nim-webui-main\examples\hello_world.nim
without problem. But fornim-webui-main\examples\text_editor\src\text_editor.nim
, I getC:\tmp\candel\src\text_editor.nim(43, 21) Error: undeclared field: 'rootFolder=' for type we bui.Window [type declared in C:\Users\USER\.nimble\pkgs2\webui-2.3.0.1-4945446001c8ab19a5f 9fbcbf1d771b9da4a324e\webui.nim(13, 3)]
Weird, using 1.9.5 text_editor
compiles and runs fine. Does your webui.nim
define (and export) the rootFolder=
proc?
Probably the Nim WebUI package does not have the latest commit?
Oh, yeah you're right it doesn't 😅. I'll also put a note that the examples use the HEAD of the gh repo, not the most recent release.
Excellent! Thank you, @neroist for the quick fix 👍
Please, @retsyo, re-test using the latest Nim-WebUI package and let us know if it gets fixed.
now text_editor.nim
can be compiled to run without problem.
but one more thing, ctrl+s
open a dialog to save as html
file. Can we bind ctrl+s
to the following code?
window.bind("Save") do (e: Event):
writeFile(filePath, e.data)
@retsyo
You'd probably have to do something with JavaScript code to bind webui_fn('Save')
to ctrl+s
. Maybe something like this:
document.addEventListener('keydown', e => {
if (e.ctrlKey && e.key === 's') {
e.preventDefault();
webui_fn('Save')
}
});
Unfortunately, you can't do this purely using the Nim wrapper, though it would be cool.
Yes, you can do it in the UI using JavaScript as @neroist mentioned 👍
I am using nim in MSYS2+MINGW64 on windows 10 64 bits. I installed webui via
nimble install webui
I can compile when I try and run
nim-webui-main\examples\hello_world.nim
without problem. But fornim-webui-main\examples\text_editor\src\text_editor.nim
, I get