2016-01-04 21:51 GMT+01:00 Bert Freudenberg bert@freudenbergs.de:
On 03.01.2016, at 14:32, Nicolai Hess nicolaihess@gmail.com wrote:
Hi Bert,
following observation:
in squeak.js, document.onkeypress = function(evt) { if (!display.vm) return true; // check for ctrl-x/c/v/r if (/[CXVR]/.test(String.fromCharCode(evt.charCode + 64)))
this test never holds (at least not with firefox on windows). The charCode is always the same, regardless whether ctrl-key is pressed
or not, so it always handles those
shortcuts as squeak-shortcuts (ctrl+v is handled as "paste author
initials", not as "paste text to browser window")
(this is not an issue for chrome, because it does not use keypress, but
the keydown events for cut&paste)
changing this to
if (evt.ctrlKey &&
/[cxvr]/.test(String.fromCharCode(evt.charCode)))
makes it working.
another issue is, that in firefox on windows, the "paste event" is never
fired for non-editable htmlelements (it works for textareas and inputfields).
But we can make the whole document "editable" with document.body.contentEditable = true (maybe it is enough to do this for the canvas elemement).
with this changes, copy , cut & paste are working in firefox (only
tested on windows).
We may have to make this browser-dependent :(
I was afraid of that. Maybe this "trick" will work:
http://andrewduthie.com/2015/08/29/capturing-a-paste-event-in-firefox/ adding somewhere a nonvisible div area with contentEditable=true.
If we make the canvas content-editable then on iOS the browser will zoom into the canvas as soon as you tap it … which OTOH may not be worse than what we have now (but I do remember some problem which led me to disabling it again).
Fabio started working on real keyboard support for touch devices but it’s not finished yet, see https://github.com/bertfreudenberg/SqueakJS/pull/42
looks interesting.
- Bert -