Closed peitschie closed 10 years ago
Another related link with some information: http://4pcbr.com/topic/how_to_open_keyboard_on_ipad_with_js
Some more playing around with the 4pcbr link:
One possible way to skirt this issue is:
A catch: after any OpInsertText
execution, focus is lost and is always restored thanks to odtDocument.subscribe(ops.OdtDocument.signalOperationEnd, restoreFocus);
There is no way to get this to work in iOS, so you can enter only 1 character after which the keyboard hides.
Solving that issue is the primary purpose of point 1 & 2.
The blur/focus required before/after every op for performance and stability reasons as a result of the event trap (and hence window selection) being inside the cursor node. Removing and re-adding the cursor node with an active selection causes significant performance problems (8de8dde), and can even throw errors in Firefox (c665b1a).
The ONLY reason for placing the event trap inline in the cursor is to accurately position the IME menus on various operating systems when a composition event occurs. If iOS has no IME system (or we choose to not support it for now), there is no compelling reason for the event trap to be inside the cursor, which allows the trap to be moved outside the main document content. This negates the need for the blur/focus after every operation, allowing continuous typing to occur.
Fixed by #390 and #410.
Due to some magical focus-ignoring code Apple has decided to put in Safari, calls to element.focus() have no effect unless they are fired within a click event or similar (see http://www.quora.com/Mobile-Safari-iPhone-or-iPad-with-JavaScript-how-can-I-launch-the-on-screen-keyboard/answer/Han-Wei).
Currently, this means that the on-screen keyboard is never activated on an iPad.
Virtual cursors would help somewhat with this as event trap would not be removed & re-added after each cursor move (as currently happens). They would still not solve the issue with how to capture the focus on page-load however.
One library I found seemed to hint that the focus event could be captured from a synthetic click event, but so far I haven't been able to reproduce this: http://ftlabs.github.io/fastclick/examples/focus.html.
I've put together a test page to help with diagnosis of this issue here: https://github.com/peitschie/WebODF/compare/ipad-focus?expand=1