Android4.3 (KitKat / Using Chromium WebView) How to listen onfocus DOM event in WebView?

I searched almost everywhere on the Internet without a visible solution.

I have my own Android application that has a contentEditableWebView. (which has the original HTML sample with some formatting and several images in it)

Currently, when the user inserts something, we have several problems

  • First of all, Android does not respect the caret position: when a sample of text is inserted at the bottom of the contentEditablediv; it will be inserted at the beginning instead.
  • The same thing happens when the test runs automatically: when the user selects something from the startup list in the middle of editable content, the sentence is inserted instead at the beginning of the content.

Here are my further findings:

  • onpaste the event does not fire (which is the most obvious way to detect if something is inserted)
  • I tried to use Mutation Observers ; although they worked on Desktop Chrome, I got an "object is not defined" error when I tried it on the device.
  • When you paste content, only tags are triggered keyup, inputand keydown. (* I attached to any possible event that I can think of , they were the only ones that work.

Wherein:

  • When a user inserts something, I get an event keydownfollowed by an event input;
  • When the user enters something, I get a sequence of events keydown input keyup;
  • -, N input ( N, 1 5, ).

( , keyup)

,

  • selectionRange ( ) , - ,
  • innerHTML contentEditable ;
  • input, 100ms, , keyup.
    • , ,
    • ,
      • diff/merge innerHTML innerHTML;
      • "diff/merge";
      • contentEditable innerHTML ;
      • ;
      • .

( ) .

- ? .

+3

All Articles