caret

Javascript: how to get line/col caret position in textarea?

旧街凉风 提交于 2019-12-12 09:26:52
问题 I can not find the solution. I've tried to assume that count of \n symbols is the same with lines count, but sometimes this method works incorrectly (e.g. after paste text from clipboard) i've tried different jQuery plugins, but still unsuccessfully. any idea? 回答1: Why not just do this: Take the text content only up to selectionStart then make it an array by splitting at eol p = $('#Form_config').val().substr(0, $('#Form_config')[0].selectionStart).split("\n"); // line is the number of lines

How to have transparent fonts except for the 'text-caret' in a textarea?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 07:46:27
问题 I have a simple textarea and I need to make transparent letters while allowing the text-caret to be visible. When I apply the following rules then I get invisible caret: textarea { background: transparent; opacity: 0; } When I type invisible text, I need to see the text-caret move. EDIT: I need to make editor to edit td cell in table. When I click on a cell I show a textarea and start typing. On a each character letter, I insert a context in a cell. After that, I hide a textarea. 回答1: This

Set cursor position in content-editable div

血红的双手。 提交于 2019-12-12 07:35:15
问题 Summary : I am trying to achieve the effect where when user types a ( or [ in the content-editable div , the second ) or ] is auto-inserted, and the caret be positioned between the two of them, that is, between ( and ) . FIDDLE Type to the right of the -- s and see how in the first line it works while doesn't work in the second. My effort: I am using this code (by Tim Down) to both highlight some part of text and set cursor position. The former works but latter doesn't :( function

JavaFX 8: Missing caret in switch-editable ComboBox

故事扮演 提交于 2019-12-12 04:32:42
问题 The caret of an editable ComboBox is missing after porting an application from JavaFX 2.2 to JavaFX 8. The ComboBox should be switched to editable on selecting an item. I tested it under Windows 8.1 with Oracle JDK 1.8 Update 102 and Update 112. When the ComboBox lost focus and regained focus, the caret is visible. It actually works on JavaFX 2.2 after changing the lambda to an interface implementation and removing the Platform.runLater . I included a SSCCE for testing: import javafx

Custom Caret not being set on initialization in c#

旧时模样 提交于 2019-12-12 03:34:58
问题 I have (painfully) written a stable console control, but am having a tiny issue regarding when starting the object the Caret is not being set to my custom one until I click inside the control on the form or push a key on the keyboard. I can see that I have focus successfully as the default (very faint line) Caret shows up blinking with no problems, even in spite of me constantly trying to destroy the little bugger. (sorry for condensing some of the code. SO limits to 30,000 characters) Here

c++ win32 hide (disable) caret from an edit box

ε祈祈猫儿з 提交于 2019-12-12 00:49:17
问题 I'm trying to make it so that a user can select text from a read-only edit box, but he won't see the blinking caret. I've been able to make the caret disappear from the edit, but it can still be seen for an instant. This is my code for the subclass: LRESULT CALLBACK UserInfoProc (HWND hUserInfoWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { HideCaret(hUserInfoWnd); return DefSubclassProc(hUserInfoWnd, uMsg, wParam, lParam); } It's a modest bit of

Java Swing JTextArea Line number

99封情书 提交于 2019-12-11 17:42:20
问题 This count line number of textarea. The code works correctly, but when run this code the textarea is not active, the caret is hidden and the keyboard keys not work unless I click on textarea. code: import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.Element; public class LineNumber extends JFrame

Rewrite a IE Code to a FF Code

♀尐吖头ヾ 提交于 2019-12-11 14:38:17
问题 This is the code (now is full): HTML: <div id="content" contentEditable="true" onkeyup="highlight(this)">This is some area to type.</div> Javascript: function highlight(elem){ // store cursor position var cursorPos=document.selection.createRange().duplicate(); var clickx = cursorPos.getBoundingClientRect().left; var clicky = cursorPos.getBoundingClientRect().top; // copy contents of div var content = elem.innerHTML; var replaceStart = ''; var replaceEnd = ''; // only replace/move cursor if

Get style at caret position in a JTextPane

会有一股神秘感。 提交于 2019-12-11 14:00:06
问题 I have a basic text editor that can style documents (bold, underline, italicize, underline, align left/right/center, color, font size/family), and that all works great. The problem I'm having is that I want the style to set my buttons and boxes to the correct styling for where the caret is. Say, for example, I have the string the quick brown fox jumps over the lazy dog When I click between the u and i in quick, I want my italicize button to be toggled on to indicate that the text where the

Cursor Positioning in ContentEditable Div

99封情书 提交于 2019-12-11 12:06:53
问题 I have a contenteditable div where I catch certain words and wrap it with a span. And I try to do this while the user is typing. Currently, I update the html content of the div by jQuery: $(div).html($(div).html().replace(....)) However, the moment this is run, the cursor position in the div returns to the very first line. Is there a different method in updating the contents of the contenteditable without losing the cursor position? 来源: https://stackoverflow.com/questions/20218043/cursor