Bonito.jl
Bonito.jl copied to clipboard
Keyboard input doesn't work
I'm not sure whether this is an issue with JSServe or WGLMakie, but the Textbox widget from WGLMakie doesn't work with JSServe.
i can't get Makie.Textbox to work either (ditto for Menu). i think the intention is you have to refactor your code to use Bonito.TextField (Dropdown) instead. like this:
julia> using Bonito
julia> app = App() do
TextField("default text")
end
it would be unfortunate if a refactoring is needed, as then the same code can't be used to create a desktop app with GLMakie and a webapp with WGLMakie.
Yeah this is a bug that will get fixed hopefully :)
Bonito.TextField
should be a good workaround for now!
i might have some time to help. would this be a good issue for someone new to makie's internals to tackle? if so, point me in the right direction.
Cool! :) I'm not sure what the bug is ... So first it would be nice to nail down where things go wrong: Maybe here?: https://github.com/MakieOrg/Makie.jl/blob/v0.19.5/src/makielayout/blocks/textbox.jl#L187-L193
Events are collected on JS here:
https://github.com/MakieOrg/Makie.jl/blob/v0.19.5/WGLMakie/src/wglmakie.js#L169-L174
If you dev WGLMakie
you can just add e.g. console.log(event.code)
in there and then look into the browsers js console to see what happens.
You may need to close the display tab and run rm(Bonito.bundle_path(WGLMakie.WGL))
for Bonito to pick up the changed JS code...
You could also start by looking into what happens here: https://github.com/MakieOrg/Makie.jl/blob/v0.19.5/WGLMakie/src/events.jl#L15-L49
It does look a bit like events.unicode_input
isn't even triggered there?
Maybe the fix is to just push the keybord button there...
the problem is not that one can't input text to the box, but that the box is just rendered as text (with an html p tag). specifically, with this julia code:
using Bonito
using WGLMakie
import WGLMakie as W
App() do
fig = W.Figure(size=(640,480))
W.Textbox(fig[1,1], placeholder="default text")
end
i get this:
where as using a bonito textfield i get this:
Ah, really? That's not actually supposed to work 😅 You need to do:
App() do
fig = W.Figure(size=(640,480))
textbox = W.Textbox(fig[1,1], placeholder="default text")
return DOM.div(fig)
end
so i put some print statements in those three spots. keydown
and code_to_keyboard
both seem to be working properly, but on(topscene, events(scene).unicode_input; priority=60) do char
seems never to be called. how does one push the button there?
the on(topscene, events(scene).keyboardbutton; priority=60) do event
method here:
https://github.com/MakieOrg/Makie.jl/blob/v0.19.5/src/makielayout/blocks/textbox.jl#L215
doesn't seem to be called either despite the keyboardbutton observable being updated here:
https://github.com/MakieOrg/Makie.jl/blob/v0.19.5/WGLMakie/src/events.jl#L92
i put print statements in both places. the latter assignment is executed, while the former function is not.