caret

JavaScript get word before cursor

北战南征 提交于 2019-11-30 13:12:49
问题 Okay, I've been looking all over the web to find a solution but I couldn't find one, is there a way to get the word before the caret position in an editable div so a bit like: This is some| demo texts This should return the word "some"... I don't know if this is possible, I would be glad for any help, thanks :). 回答1: With using Caret Position finder method provided here this will do what you want. function ReturnWord(text, caretPos) { var index = text.indexOf(caretPos); var preText = text

Mobile Safari - Input caret does not scroll along with overflow-scrolling: touch

被刻印的时光 ゝ 提交于 2019-11-30 12:02:59
问题 I know that Mobile Safari won't fire events while in "momentum" (-webkit-overflow-scrolling: touch;) scrolling. But this is not entirely the same thing, because Safari handles the (blinking) caret of an input internally. <div id="container"> <input type="text" /> <div class="filling"></div> </div> #container { position: absolute; top: 20px; bottom: 20px; width: 50%; -webkit-overflow-scrolling: touch; overflow-y: auto; border: 1px solid black; } input { margin-top: 60vh; } .filling { height:

twitter bootstrap issue : Right align the caret in the dropdown header

蓝咒 提交于 2019-11-30 11:02:45
I have an issue with the right alignment of the caret. Using .pull-right in the span makes it go to the top right corner. How can I make it vertically centered again ? I also would like to align the text to the left http://www.bootply.com/r8x7g5Bw5R <div class="btn-group cust-dropdown"> <button type="button" class="btn btn-default dropdown-toggle cust-dropdown" data-toggle="dropdown"><span class="caret pull-right"></span><span>test</span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="#">test</a></li> <li><a href="#">tes2</a></li> <li><a href="#">test3</a></li> </ul> </div> and

How to prevent memory leak in JTextPane.setCaretPosition(int)?

ぐ巨炮叔叔 提交于 2019-11-30 07:35:57
问题 I'm working on a Java application with Swing-based GUI. The application uses JTextPane to output log messages as follows: 1) truncate existing text to keep total text size under the limit; 2) append new text; 3) scroll to the end (actual logic is slightly different, but it's irrelevant here). I was using Eclipse with JVM Monitor to determine reasonable text size limit and found significant memory leak. I tried to remove UndoableEditListener s from the underlying document and disable automatic

TextBox Cursor is NOT blinking

主宰稳场 提交于 2019-11-29 16:03:27
I have a WPF datagrid (4.0) with a custom column (derived from DataGridTextColumn). In GenerateEditingElement I create a custom textbox control (with an additional button) and like to set the cursor into it so that the user can directly start editing. The closest I get is that the caret is shown but is not blinking and I need an additional click to start editing. All other stuff (binding, ...) is working nicely Any ideas? Since the caret is shown, but not blinking, then I am guessing your control has Logical Focus, but not Keyboard Focus. How are you setting the control as Focused? myControl

Textarea X/Y caret coordinates - jQuery plugin [duplicate]

自古美人都是妖i 提交于 2019-11-29 11:35:22
This question already has an answer here: How do I get the (x, y) pixel coordinates of the caret in text boxes? 3 answers I'm looking to get the X/Y coordinates of the caret within a textarea on key down. I've searched vigorously but without any luck whatsoever, it seems you can get the position, but not the on-screen X/Y coordinates. James The only viable way of doing this, AFAIK: Append the contents of the TEXTAREA to a DIV Append the DIV to the DOM Place a SPAN inside the DIV at the character offset of the caret . Take the offset of the SPAN ( $(span).offset() ...) and minus the offset of

How to get number of rows in ContentEditable area and current caret line position?

北慕城南 提交于 2019-11-29 10:50:11
my question has two parts, but they are related. Firstly - I have Contenteditable DIV with some text and I need to get total number of rows (lines) of this DIV. Is it possible ? Secondly - I need to get caret row position, if it is on row number 1, 2, 3, etc.... Can anybody help ? The direct answer is that there is no method that actually gets you those numbers. However, there are a number of different work arounds which you can apply to estimate (I use estimate , because I don't think they can be made 100% accurate) those values. To answer your first question, how to get the number of lines

Move the cursor position with Javascript?

ⅰ亾dé卋堺 提交于 2019-11-29 04:22:22
I'm looking to move the caret exactly four spaces ahead of its current position so that I can insert a tab properly. I've already got the HTML insertion at the caret's position working, but when I insert the HTML, the caret is left behind. I've spent the past hour or so looking at various ways to do this and I've tried plenty of them, but I can't get any of them to work for me. Here's the most recent method I've tried: function moveCaret(input, distance) { if(input.setSelectionRange) { input.focus(); input.setSelectionRange(distance, distance); } else if(input.createTextRange) { var range =

Java: column number and line number of cursor's current position

两盒软妹~` 提交于 2019-11-28 23:44:13
I want to know the column number and row number where the cursor in JTextArea. ie. in notepad when i m at first line than status bar shows Ln 1, Col 1. thanks in advance... Here is the code import java.awt.BorderLayout; import javax.swing.*; import javax.swing.event.*; public class caretDemo extends JFrame { // Two controls, one is the editor and the other is our little status bar at the bottom. // When we update the editor, the change in caret will update the status text field. private JTextArea editor; private JTextField status; // Start of our caretDemo class public caretDemo() { setTitle(

Remove text caret/pointer from focused readonly input

时光怂恿深爱的人放手 提交于 2019-11-28 17:26:16
I am using an <input readonly="readonly"> , styled as normal text to remove the appearance of an interactive field, but still display the value. This is very useful to prevent a user from editing a field, while still being able to post the value. I realize this is a convenience method and that there are several workarounds, but I want to use this method. Problem: The blinking caret still appears when the field is clicked/focused. (At least in FF and IE8 on Win7) Ideally, I would like it to behave as it normally does, focusable, but without the blinking caret. Javascript solutions welcome. n3on