Commit graph

9 commits

Author SHA1 Message Date
Olivier Goffart
9ec6ed0406 wasm: fix tab and back tab
The situation differs depending if the widget show the virtual keyboard or not:
For widget that don't show the virtual keyboard, we rely on the winit events,
but for some reason we don't recieve WindowEvent::ModifiersChanged events with
wasm. Since the event handling in winit is about to be rewriten, I did not
bother reporting the bug upstream, but just work around by using the deprecated
API. So that way shift + tab will no longer be understood as just tab.

For widget using the virtual keyboard, then the event handling is in
wasm_input_helper.rs.  There is a couple of issues:

 - We must map shift+tab to backtab.
 - We need to prevent the default events to trigger, so that tab and other
   shortcuts don't take effect on the browser. Winit already inhibit these
   events so we must do the same otherwise tab and shift+tab would change the
   html focus.
 - By luck, tab used to give the focus back to the canvas before (see previous
   point) and that's why it worked. But now that we don't do that anymore,
   hiding the virtual keyboard should actually re-focus the canvas
 - That will cause the focus event to be intercepted by winit, and will cause
   recursions and borrow error, so we make sure that we do not recurse when
   getting the focus event
2022-04-22 13:58:37 +02:00
Simon Hausmann
b4f7d135d6 Fix cargo fmt 2022-03-25 11:52:37 +01:00
Olivier Goffart
e6619438c6
Janitor: update a comment to match the implementation 2022-03-25 10:50:33 +01:00
Olivier Goffart
b4bbe0b6df
Wasm: Hack to get input working despite composition (#1101)
Since we don't have yet support for IME in Slint, simulate that by inserting
the text anyway, and rollback using backspaces.
2022-03-24 21:08:44 +01:00
Olivier Goffart
8984eadc05 Wasm: polish the mobile keyboard input
ensure that we don't add the text twice in firefox, and that not every
word is capitalized in chrome
2022-03-24 18:48:24 +01:00
Simon Hausmann
60bb30df8f Hide the cursor on mobile Safari 2022-03-24 11:55:56 +01:00
Olivier Goffart
bd44afdbf4 Wasm: When getting native callback, make sure to call the winit event loop
Otherwise it won't be woken up if the window needs a redraw
2022-03-23 17:43:48 +01:00
Olivier Goffart
b259656f4c Wasm: fix dead keys on firefox desktop
We don't want to intercept the press of the non dead key when it is composed
with a dead key. Let the input event handle it
2022-03-22 15:35:02 +01:00
Olivier Goffart
e017d5118b Wasm GL backend: use a <input> element so it show the keyboard on mobile
cc #215

Handle Input event from the input directly instead of going through winit
for the TextInput.

Note that this doesn't handle the composition event well, so the text is
only considered written when it is accepted
2022-03-22 13:33:31 +01:00