caret

Caret position in pixels in an input type text (not a textarea) [duplicate]

你离开我真会死。 提交于 2019-12-17 15:39:48
问题 This question already has answers here : How do I get the (x, y) pixel coordinates of the caret in text boxes? (3 answers) Closed 5 years ago . UPDATE : duplicate of Get cursor or text position in pixels for input element. TL; DR - use the incredibly lightweight and robust textarea-caret-position Component library, which now supports <input ype="text"> as well. Demo at http://jsfiddle.net/dandv/aFPA7/ Is there a way to know where the caret is inside an HTML text field? <input type='text' /> I

Caret position in pixels in an input type text (not a textarea) [duplicate]

无人久伴 提交于 2019-12-17 15:39:09
问题 This question already has answers here : How do I get the (x, y) pixel coordinates of the caret in text boxes? (3 answers) Closed 5 years ago . UPDATE : duplicate of Get cursor or text position in pixels for input element. TL; DR - use the incredibly lightweight and robust textarea-caret-position Component library, which now supports <input ype="text"> as well. Demo at http://jsfiddle.net/dandv/aFPA7/ Is there a way to know where the caret is inside an HTML text field? <input type='text' /> I

Java - Scroll to specific text inside JTextArea

微笑、不失礼 提交于 2019-12-17 04:35:07
问题 I'm trying to implement a feature inside the current program that I'm writing and I wanna learn how to scroll down to specific text inside a JTextArea. For example, lets say I have the following: JTextArea area = new JTextArea(someReallyLongString); someReallyLongString would represent a paragraph, or a very large piece of text (in which the vertical scrollbar would be visible). And so what I am trying to do is scroll down to specific text within that text area. For example, lets say

jquery Setting cursor position in contenteditable div

不羁岁月 提交于 2019-12-17 03:54:53
问题 The old version of the question is below, after researching more, I decided to rephrase the question. The problem as before is, I need to focus a contenteditable div without highlighting the text, doing straight up focus highlights the text in Chrome. I realize that people solved this problems in textareas by resetting the caret position in the textarea. How can I do that with a contenteditable element? All the plugins I've tried only works with textareas. Thanks. Old Phrasing of the question

How to get the focused element with jQuery?

给你一囗甜甜゛ 提交于 2019-12-17 02:52:17
问题 Using jQuery, how can I get the input element that has the caret's (cursor's) focus? Or in other words, how to determine if an input has the caret's focus? 回答1: // Get the focused element: var $focused = $(':focus'); // No jQuery: var focused = document.activeElement; // Does the element have focus: var hasFocus = $('foo').is(':focus'); // No jQuery: elem === elem.ownerDocument.activeElement; Which one should you use? quoting the jQuery docs: As with other pseudo-class selectors (those that

Get caret HTML position in contenteditable DIV

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 16:06:55
问题 I am having troubles figuring out how to get caret position in a DIV container that contains HTML tags. I am using this JavaScript function to do that: function getCaretPosition() { if (window.getSelection && window.getSelection().getRangeAt) { var range = window.getSelection().getRangeAt(0); var selectedObj = window.getSelection(); var rangeCount = 0; var childNodes = selectedObj.anchorNode.parentNode.childNodes; for (var i = 0; i < childNodes.length; i++) { if (childNodes[i] == selectedObj

Is it possible to made a TCombo edit caret 'wider' or to 'bold' it?

倾然丶 夕夏残阳落幕 提交于 2019-12-13 16:06:26
问题 I have an mode that uses TComboBox.SelStart to indicate progress along the edit text string. In this mode I would like to make some kind of change to the edit caret, for example to widen it to 2 pixels or 'bold' it in some way to indicate this mode and to have it grab more attention. Is this possible? 回答1: Yes, as Alex mentioned in his comment, this can be done using API calls. Example: procedure SetComboCaretWidth(ComboBox: TComboBox; Multiplier: Integer); var EditWnd: HWND; EditRect: TRect;

Change the size of the caret in a TextField (JavaFX 8)

邮差的信 提交于 2019-12-13 09:35:37
问题 I'm trying to resize the caret in a TextField without modifying the font size, but I can not do it. Does anyone know how to do that? Thanks! 回答1: I have no idea why you would want to do this. And this probably won't give you exactly what you want, but it does change the size of the caret. Note that the big caret will still be clipped to be within the bounds of the containing TextField. The small line between the m and the a is the small caret. Image transfer into stackoverflow reduced clarity

How to always scroll to bottom of text area?

允我心安 提交于 2019-12-12 20:56:01
问题 How do I make it so the scroll pane is always located the bottom of the scroll pane where the new data is being written? I can't see the new text coming in as it is written. JTextArea itTextArea = new JTextArea(10,80); new JScrollPane(itTextArea); xmlTextArea.setEditable(true); 回答1: This is what I use: DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); Here's how you implement it: public class Test { public static void createFrame() {

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

夙愿已清 提交于 2019-12-12 18:54:02
问题 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 = "<span class='spanPos'></span>"; Now , I can get the care position in the contenteditable div and also I know how to remove and add the span element at the caret position. But the thing is that while I am doing this operation, Left and Right buttons are misbehaving. Please have a look at this link