caret

Drawing a blinking caret in Winforms

家住魔仙堡 提交于 2019-12-01 13:01:41
I'm developing a custom control, which most resembles a text area. I am drawing text, which works correctly, and accepting input which also works.. But I (the user) am left guessing where the caret is while I type, since I'm doing everything manually. How do I draw a blinking caret to show where I am currently typing? Is there a standard way to do this? ChrisW I think that, annoyingly, there is no managed API for Carets. You must, therefore, either PInvoke to the Win32 functions for carets, or, implement that functionality yourself (i.e. painting and hiding a blinking caret, when and only when

Get cursor-position in contenteditable div

喜欢而已 提交于 2019-12-01 13:01:05
I found the following code here on SO to get the position of the cursor of a contenteditable div, however it always returns 0. The function that should retrieve the position: new function($) { $.fn.getCursorPosition = function() { var pos = 0; var input = $(this).get(0); // IE Support if (document.selection) { input.focus(); var sel = document.selection.createRange(); var selLen = document.selection.createRange().text.length; sel.moveStart('character', -input.value.length); pos = sel.text.length - selLen; } // Firefox support else if (input.selectionStart || input.selectionStart == '0') pos =

Set caret position in contenteditable div

依然范特西╮ 提交于 2019-12-01 10:47:28
问题 Intro When editing the content of a contenteditable DOM Object, different browsers have different behaviours. For instance, Firefox 18.0 creates a new paragraph ( <p> ) or a line break <br/> in some instances while Chrome 24 creates a <div> . In order to cope with this, I'm listening to the DOMNodeInserted event and replacing the new inserted nodes with p tags. Problem The problem is placing the caret in place. I've read tons of posts in SO regarding this same subject but none of the provided

XY Caret Coordinates inside a contenteditable div

纵饮孤独 提交于 2019-12-01 06:39:08
问题 I am looking for a way to get the caret x y coordinates inside a contenteditable div, in a similar manner to how you can get the mouse coordinates using window.event since I need to open a pop-up exactly where the user is with the caret inside the contenteditable div. How can I do this? Many thanks! 回答1: Here's one approach: Coordinates of selected text in browser page However, in some circumstances this will not give you coordinates, in which case you'd need to fall back to inserting an

How to place the caret where it previously was after replacing the html of a contenteditable div?

纵然是瞬间 提交于 2019-12-01 06:06:39
问题 I have a contenteditable div where I replace hashtags with clickable links when the user clicks on space or on enter. The user writes down: I love but there is no fish at home| He then realizes he made a mistake and then decides to go back and write I love #sushi | but there is no fish at home #sushi gets replaced by: <a href="https://google.com/sushi>#sushi</a> Notice that the | shows the position of where I want the caret to be when the user presses spacebar. My current "placeCaretAtEnd"

How to use TinyMCE functions on text without actually selecting that text?

半世苍凉 提交于 2019-12-01 05:50:39
I have various <div> s on my page, which, when clicked, convert into TinyMCE editor sections. So the user can just double click on the div and then edit the text within it using TinyMCE. My question is - is it possible to run the TinyMCE functions on a <div> without actually having the text inside selected? What I mean is, I want to implement the following use case: User clicks on a <div> . <div> activates a TinyMCE session on itself. User can now use the buttons on the TinyMCE toolbar to edit all the text in the div, without having to actually select the text manually using the cursor.

How do you programmatically move the caret of a Flex TextArea to the end?

徘徊边缘 提交于 2019-12-01 05:21:27
I'm trying to move the caret in a Flex TextArea to the end after appending some text from my code. I've looked through the reference documentation for TextArea and its underlying TextField but it appears there is no method provided to handle this. One approach I've tried is to set focus to the text area and dispatch a KeyUp KeyboardEvent with the event's key code set to the "End" key, but this doesn't work. Any ideas on how to do this? Thanks. Try this textArea.selectionBeginIndex = textArea.length; textArea.selectionEndIndex = textArea.length; For people looking for the Spark component way to

How to use TinyMCE functions on text without actually selecting that text?

*爱你&永不变心* 提交于 2019-12-01 03:56:52
问题 I have various <div> s on my page, which, when clicked, convert into TinyMCE editor sections. So the user can just double click on the div and then edit the text within it using TinyMCE. My question is - is it possible to run the TinyMCE functions on a <div> without actually having the text inside selected? What I mean is, I want to implement the following use case: User clicks on a <div> . <div> activates a TinyMCE session on itself. User can now use the buttons on the TinyMCE toolbar to

TextBox Caret Styling

不羁的心 提交于 2019-11-30 17:17:52
I've found a few things on setting CaretBrushes in WPF4, but has anybody actually ever changed the caret itself? What I'd like to do is use the OVERWRITE caret in INSERT mode. I've seen a hack from .Net 3.5 times , but it is unperformant and lacks behind actual cursor movement... It would be great if the Caret had a Template - That would be consistent with the whole WPF idea... Any advice? The CaretElement is an internal sealed class and not possible to customize through a data template for example. At least, the caret brush is possible to change. <TextBox Text="This is some random text"

TextBox Caret Styling

你说的曾经没有我的故事 提交于 2019-11-30 16:33:59
问题 I've found a few things on setting CaretBrushes in WPF4, but has anybody actually ever changed the caret itself? What I'd like to do is use the OVERWRITE caret in INSERT mode. I've seen a hack from .Net 3.5 times, but it is unperformant and lacks behind actual cursor movement... It would be great if the Caret had a Template - That would be consistent with the whole WPF idea... Any advice? 回答1: The CaretElement is an internal sealed class and not possible to customize through a data template