Note that there are some explanatory texts on larger screens.

plurals
  1. POA better way of keeping track of cursor position in a text-field while auto-correcting?
    primarykey
    data
    text
    <p>I am working on a jQuery plugin for converting Latin characters to Japanese kana symbols (<a href="http://lab.cmikavac.net/autokana/" rel="nofollow">live example</a>) in real-time (auto-correct) and it works correctly if I'm not typing too fast.. Which is a problem.</p> <p>For example:</p> <blockquote> <p>wakarimasu -> わかります</p> </blockquote> <p>However, when I type at my normal speed I get this:</p> <blockquote> <p>wakarimasu -> わかりあすm (which is actually wakariasum, cursor between "す" and "m" in the end)</p> </blockquote> <p>If I type it without "su", I get this:</p> <blockquote> <p>wakarima -> わかりあm (which is actually wakariam, cursor between "あ" and "m" in the end)</p> </blockquote> <p>I figured out why and how this is happening. Basically, "ri - り" symbol is still converting from Latin to Japanese kana while I already typed "m" in and it finishes just a little bit before I manage to type "a" in. Since my function positions the cursor after each conversion, it positions the cursor between "ri" and "m" and that is where my "a" ends up.</p> <p>This happens for other words as well, but I took this one as an example.</p> <p>Is there a way I could track the cursor position in a smarter way or is there a way to update/convert/replace only parts of textfield without updating the whole textfield (the way it works now is it fetches what is in the textfield, replaces Latin with kana inside a variable inside the function, updates the textfield with the new string from a variable and then positions the cursor)? Telling visitors not to type too fast wouldn't really be the way to go..</p> <blockquote> <p>Legend: wa=わ ka=か ri=り ma=ま su=す a=あ</p> </blockquote> <p>Source can be viewed at the link I provided. Thanks.</p> <p><em>Edit: One more thing to think about is that a user might move cursor left and right to add or remove characters/symbols. This complicates positioning a little bit but it works at the moment.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload