views:

42

answers:

2

Like the title reads, I want to change the character of a caret. Maybe make it a letter or something?

Thanks.

A: 

That's not possible in HTML/JavaScript.

EricLaw -MSFT-
I've actually just recently found an example here: http://shachi.prophp.org/demo.html but I can't seem to extract the necessary elements and integrate it into my code... but thanks anyway.
four33
@scuba - That's not replacing the caret, it's hiding it and showing something another block element :)
Nick Craver
OK, do you know of a simpler way to do that? Or a way to explain it to a JS newb like myself? I can't make sense of this demo...
four33
You'll note that the demo page doesn't work properly with text selection, zoom, etc.
EricLaw -MSFT-
+1  A: 

You can do something near this, but its very dificult.

  1. In you textfield bind a event to keydown, for example.
  2. Each char typed, you slide a floating <img> above textarea.
  3. If user click in textarea, update position getting X and Y from onclick.

Obs: the font must be monospaced. Ex: if every font have 20px and user press backspace, you slide this gif to the left 20px.


EDIT

I just made a hello world, in jsfiddle.

Of course, it's an example, but test typing and use backspace and enter to see caret go back and foward.

In this example there are a lot of bugs to fix, like:

  • Use of <backspace> that cleans all line

  • Use of arrows that in overflow textarea margins

  • Use of mouse must update caret position...

Topera
Wow, this is great stuff. It will take me some time, but I think I can learn a great deal from this. Thanks Topera.
four33
Ok... just pay me (+1 vote?), lol :D
Topera
I SHALL! I shall register an account and provide you with the tidy sum of +1 vote for your good deeds today!
four33
There are many other cases to consider that make this difficult; e.g. selection of text, moving about using hotkeys, zoom, etc. FWIW, I couldn't get the jsfiddle demo to work at all in IE.
EricLaw -MSFT-