codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
372 stars 76 forks source link

No keyboard on touch devices #4

Closed codefrau closed 4 months ago

codefrau commented 10 years ago

Maybe we need another hack than content-editable? It works fine on desktop Chrome though.

codefrau commented 9 years ago

Currently the keyboard is not shown at all, I removed the content-editable hack. One possibility would be to add a hidden text field (which might also help with copy/paste). In some images we even get an event for when to show the keyboard (via ImmX11/ImmWin32). Otherwise we might have an always-visible "keyboard" button that brings up the keyboard.

codefrau commented 8 years ago

I added a button, but it still uses content-editable and only tested on iOS: 2c28141c5d9044d4727e93fcdd5de296aad89732 We need some proper magic. E.g. it works very badly with predictive text input, when multiple characters are replaced ... Also copy/paste is still an issue #74

LinqLover commented 4 years ago

On Chrome for Android, keyboard inputs are not recognized at all, even though I can open up the keyboard thanks to the keyboard button. Sounds as if a hidden text field might be a good solution.

Just for interest, can you use such a dummy field for better recording of events or would you actually have to fill it with some dummy text to get notified when the text changes? And how would you deal with that text field's focus to avoid the keyboard being shown permanently? I don't think the ImmPlugin is supported by all older images, probably not even by non-Morphic projects such as MVC or SqueakShell.

codefrau commented 4 years ago

The plugin would use .focus() / .blur() to manage the focus of the hidden field. The browser will respond by showing/hiding the on-screen keyboard.

As for having a dummy character in the field - I'm not sure. Guess we need to test what events browsers actually deliver.

To support MVC etc we do need the keyboard button I think, because MVC is simply polling the keyboard queue. There might be a hack to walk up the stack context chain to see what kind of Controller is currently doing the polling, but I'm not confident that would even work, let alone be reliable.

ErikOnBike commented 4 years ago

A character or two might be needed in the hidden input field to allow a backspace or delete to be signalled as input event (or something similar, don't fully remember and writing this away from the computer). As keyboard event I think they always will be signalled. But not sure if that works on Android. Be careful this event mixing of input va key events is or can be quite a challenge. For IME there can be multiple key and/or input events leading up to a single character being inserted. That is, events can be composing. Copy/paste might need special handling as well. I'm also busy with this kind of stuff at the moment. Will try to give an update if I discovered some useful solution.

LinqLover commented 4 years ago

It will be even harder when it comes to non-stroke events (keyDown, keyUp). Probably they could only be simulated if the dummy field receives a stroke. And what's about arrow keys and so on? At least under Android, some keyboards offer arrow keys, so it would also be necessary to track the caret focus of the dummy field. Whew!

tonyg commented 2 years ago

Regarding just plain text input on mobile devices, no control- or command-keys, please see https://github.com/codefrau/SqueakJS/pull/135, which could be a basis for discussion. It's pretty janky still but might be an approach polishable into something usable.

codefrau commented 4 months ago

Fixed by 4ccac8c9cb566fc5f675aa69f5b02ae96cb63b17