caret

How to get range of characters between @ and caret in contenteditable

我的未来我决定 提交于 2019-12-02 09:12:46
I have a contenteditable div and it contains other tags and not only plain text. Only one @ is allowed in. How can I get the range of the characters between @ and caret if such a range exists? Michail Michailidis Ha that was easier than I thought!. Based on this easy to overlook question: Div "contenteditable" : get and delete word preceding caret I forked its jsfiddle and here is mine working as expected: http://jsfiddle.net/52m2thu2/1/ function getWordBetweenAtAndCaret(containerEl) { var preceding = "", sel, range, precedingRange; if (window.getSelection) { sel = window.getSelection(); if

Get caret position (x, y) in input TextField AS3?

我的未来我决定 提交于 2019-12-02 08:25:31
问题 I need to get the position of the caret in my input textfield. I don't need to set the position, i need to get the current location of the caret. Can't figure this out and it's driving me crazy! 回答1: Check the Texfield.caretIndex property and TextField.getCharBoundaries() method in documentation. It's actually easy but it gets tricky when the field is empty or the next char is a empty/newline. import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldType; import

Using custom Caret in JTextField for accessibility

孤街醉人 提交于 2019-12-02 07:20:29
问题 I'm programming a Swing Application and I have a friend that read much the Bible. This app have searches by text or passage. But my friend only can see big font sizes and contrasted colors . I change the color of caret for the textField with setCaretColor , where the user input the text to search. The caret show like a rectangle with the same hight of font, but the width is little and I think that my friend cans not see. Is there any way for change the width of the caret for show more bigger?

Get caret position (x, y) in input TextField AS3?

霸气de小男生 提交于 2019-12-02 06:31:41
I need to get the position of the caret in my input textfield. I don't need to set the position, i need to get the current location of the caret. Can't figure this out and it's driving me crazy! Check the Texfield.caretIndex property and TextField.getCharBoundaries() method in documentation. It's actually easy but it gets tricky when the field is empty or the next char is a empty/newline. import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldType; import flash.events.KeyboardEvent; import flash.geom.Rectangle; var t:TextField = new TextField(); t.x = t.y = 20; t

How to change the bootstrap caret pointing position?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 05:37:12
Within bootstrap the caret is always pointing down. I would like it to point to the right when when the menu is closed. See demo. Demo: http://jsfiddle.net/Maty2/ HTML <div class="functionbox funtog"> <a class="btn dropdown-toggle fleft" data-toggle="collapse" data-target="#demo-1" href="#"><span class="caret"></span></a> <h3>Recent</h3> </div> <div id="demo-1" class="collapse in"> <div class="whitebox"> <div id="myprojs">Hide this</div> </div> </div> ​ CSS .whitebox { padding: 20px; border-top: 1px dotted #b3b3b3; border-left: 1px dotted #b3b3b3; color: #444; background-color: white; position

CKEditor: set cursor/caret positon

好久不见. 提交于 2019-12-02 02:26:13
问题 How can I position the caret in CKEditor3.x? I have 2 positions and I want use insertHTML() on both positions. Pseudo-code: editor.setCaret(20); // function does not exists editor.insertHtml('::'); editor.setCaret(40); // function does not exists editor.insertHtml('::'); I have tried (to set caret to position: 20): var ranges = []; var range = new CKEDITOR.dom.range( this.document ); range.startOffset = 20; range.endOffset = 20; ranges.push( range ); editor.getSelection().selectRanges( ranges

Detecting text selection in JTextArea

我的未来我决定 提交于 2019-12-01 21:49:45
I have a JTextArea and am deteching if any text is selection, if none is then two of the menu items are grayed out. The problem I have is, when I compile and open the application I have to click on the JTextArea first and then then the menu items are greyed out, if I don't they aren't even if no text is selected. I am using the following caret listener. textArea.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent arg0) { int dot = arg0.getDot(); int mark = arg0.getMark(); if (dot == mark) { copy2.setEnabled(false); cut1.setEnabled(false); } else{ cut1.setEnabled

CKEditor: set cursor/caret positon

这一生的挚爱 提交于 2019-12-01 20:20:43
How can I position the caret in CKEditor3.x? I have 2 positions and I want use insertHTML() on both positions. Pseudo-code: editor.setCaret(20); // function does not exists editor.insertHtml('::'); editor.setCaret(40); // function does not exists editor.insertHtml('::'); I have tried (to set caret to position: 20): var ranges = []; var range = new CKEDITOR.dom.range( this.document ); range.startOffset = 20; range.endOffset = 20; ranges.push( range ); editor.getSelection().selectRanges( ranges ); This is not working. Can anybody help me please? To insert text or do something with html in the

Winforms: Screen Location of Caret Position

血红的双手。 提交于 2019-12-01 19:04:56
How can I find the screen position of the caret for a standard Winforms TextBox? You can do it only with native interop: GetCaretPos [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool GetCaretPos(out Point lpPoint); I have been using the TextBox.GetPositionFromCharIndex function. It gives coordinates relative to the top left of the the TextBox. 来源: https://stackoverflow.com/questions/1027910/winforms-screen-location-of-caret-position

How to prevent JScrollPane arrow key handling from moving caret when Scroll Pane wraps Text Pane

核能气质少年 提交于 2019-12-01 14:12:13
I have the following requirements: I need a scrollable JTextPane. The user may type into this text pane, or text may be inserted into it that is not typed by the user. Think something like an IM window. Although the window must be scrollable to allow the user to review text previously typed, the caret should never move from its position at the end of the text. Any text entered by the user will always appear at the end. In JTextPane, when the user scrolls with the scroll bar, the caret does not move. The viewport is adjusted. However, when the user presses the up and down arrow keys, the