Questions tagged [getcaretpos]

29 questions
14
votes
2 answers

Get caret index in contenteditable div including tags

I have a contentEditable div in which I have multiple tags (br, b, u, i) and text. I need to get the caret index position relative to the div, including all the tags. For example:
helldrain
  • 141
  • 1
  • 1
  • 7
10
votes
1 answer

how to get the caret position of a contenteditable div which contains images

I have this contentedittable div
minubyviubyvt
Here is an image description of the code output so I want to get the caret position of the…
doggie brezy
  • 289
  • 3
  • 16
8
votes
3 answers

Get current word on caret position

How can I get a word in textarrea by its current caret position? I tried something like this, however this returns just the words first letter upto the character at caret position. For example: if the cursor is between fo and o it returns fo and not…
yckart
  • 32,460
  • 9
  • 122
  • 129
7
votes
3 answers

Deselect default selection on JTextfield

When using JTextFields i like to set a default text. Then i run the program and this default text will automatically be selected (at least when you have only one field). In other words, if I type a letter right away, the default text will be deleted…
Ole-M
  • 821
  • 2
  • 13
  • 27
4
votes
1 answer

How do I preserve the caret position when changing a contenteditable div's text?

I'm trying to make a text editor that formats text based on what it says. For example, when you type "select", it changes the color of the word "select" to red. I'm using a contenteditable div. I was able to make it change the color, but every time…
Max Pelic
  • 41
  • 6
3
votes
1 answer

JavaScript: get cursor position in contenteditable div

I am pretty new to JavaScript and hope someone here can help me with the following: Primarily looking for a solution in IE 8 - if it can cover other browsers / versions even better. I have a page with only one contenteditable div that is created…
user2571510
  • 11,167
  • 39
  • 92
  • 138
3
votes
1 answer

Get caret position in input to capitalize words on keyup while being able to edit the content

I decided to open a new question because I was trying to capitalize the first letter of words with 4 or more letters and with the exception of a few key words and I have this working code for that: http://jsfiddle.net/Q2tFx/11/ $.fn.capitalize =…
Santiago
  • 2,405
  • 6
  • 31
  • 43
2
votes
1 answer

how to get caret position in cocoa app

I want to get current caret position in my cocoa app from any active application relative to screen position. Please let me know any solution. Thanks,
AmitSri
  • 1,209
  • 1
  • 20
  • 48
2
votes
1 answer

problem with window.getSelection() with emoji-mart (Picker component)

My code: addEmoji = () => { document.getElementById('description-text').focus(); let element = $("#span").clone()[0]; let sel = window.getSelection(); if (sel.getRangeAt && sel.rangeCount) { let range = sel.getRangeAt(0); …
2
votes
1 answer

How To Find INPUT And TEXTAREA Caret Position Coordinates Using JavaScript?

Me trying to find out caret position coordinates with respect to document(Whole Web Page) in a TextArea or Input of type="text" on JavaScript HTML DOM Events functions like onkeydown, onkeypress, onkeyup etc... For this I created the below…
Muhammad Hassan
  • 1,224
  • 5
  • 31
  • 51
2
votes
0 answers

Javascript - event keyup, keydown or keypress do not carry caret (cursor) absolute positioning

I'm trying to get absolute positioning of a caret when user is writing. I know that document.caretRangeFromPoint(e.clientX, e.clientY), but e.clientX, e.clientY are undefined if event is a key pression. I made a jsfiddle where it is obvious that…
Nico
  • 81
  • 6
2
votes
1 answer

Get product category on home page in opencart

I am using this code in latest_content.tpl file to get category name. But it is not displaying category name. How can I get category name in opencart. $categories = $this->model_catalog_product->getCategories($product_id); if ($categories) …
user3190238
  • 43
  • 1
  • 2
  • 6
2
votes
1 answer

Left and right button misbehaving when trying to add an empty span to contenteditable div

In my project, I am trying to add a span wherever the caret is in the contenteditable div. This span element will be used as getting the offset position of the caret indirectly. var _spanElem = ""; Now , I can get the…
Mr_Green
  • 40,727
  • 45
  • 159
  • 271
1
vote
1 answer

JS onclick select partial text in input - start from cursor position to the end of string (afterCaret)

I need tricky function, when I OnClick on the input field it will select text from cursor position (afterCaret) to the end of text value. I am input example textfield text When I will put cursor by clicking by mouse.. let's say in…
yan
  • 15
  • 3
1
vote
1 answer

Apache Pivot TextArea / TextInput caret position

I am not able to find, how can I get caret position of Apache Pivot TextArea and TextInput. Also I need to add a caret listener or something like that to them. The last thing I need to know is how to get caret position of these components by the…
1
2