caret

WPF RichTextBox - get whole word at current caret position

被刻印的时光 ゝ 提交于 2019-12-06 11:36:13
问题 I enabled spelling on my WPF richtextbox and I want to get the misspelled word at current caret position before the context menu with spelling suggestions is displayed. 回答1: The new way void richTextBox1_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Back) { TextPointer start = richTextBox1.CaretPosition; string text1 = start.GetTextInRun(LogicalDirection.Backward); TextPointer end = start.GetNextContextPosition(LogicalDirection.Backward); string text2 = end.GetTextInRun

TextBox CaretIndex property in ViewModel

牧云@^-^@ 提交于 2019-12-06 10:44:46
问题 Is it possible to get/set the value of CaretIndex property of a TextBox control in viewmodel in wpf via Binding defined in view? Thanks 回答1: You can not bind the property CaretIndex since it is not a DependencyProperty . It is a CLR property that does not accept binding. 回答2: The issue here is how to get the CaretIndex of the TextBox control via the view model. If you intent to get it directly by binding to the view model its impossible. As I posted in the previous answer its a CLR property

Contenteditable - extract text from caret to end of element

元气小坏坏 提交于 2019-12-06 07:03:11
问题 after skimming all possible questions and answers, i'll try it this way. I'm programming an RTE, but didn't manage to successfully extract text in a contenteditable element. The reason for this is, that each browser handles nodes and keypress (#13) events in a slightly different way (as ex.g. one creates 'br', the other 'div', 'p', etc.) To keep this all consistent, I'm writing a cross-browser editor which kills all default action with e.preventDefault(); Following scenario: 1) User hits the

Move printing position of Command Line Interface in Java without using External library

瘦欲@ 提交于 2019-12-06 06:39:02
In C, I recalled that I can move the invisible caret around the command line interface screen with respect to the line and character position, meaning I can make the program print any text anywhere on the screen. Do we have such command in Java? For instance, here is a pseudocode in C: int main(){ printf("launching program\n"); moveTo(4,3); //move to line 4 at character index 3 on the screen. printf("AAA"); moveTo(3,0); //move to line 3 at character index 0 on the screen. printf("BBB"); moveTo(2,1); //move to line 2 at character index 1 on the screen. printf("CCC"); return 0; } This will give

programmatically move caret in textbox, line up and line down

孤街醉人 提交于 2019-12-06 04:50:43
问题 I am struggling to move the caret in a textbox editing control within a DataGridView , one line up and one line down, just as a user would get when pressing up and down arrows. So I don't mean lines as what is between newline characters, I mean lines as what is between the left and right side of a textbox. I cannot use GetCharIndexFromPosition and GetPositionFromCharIndex because not all text will always be shown in the textbox display area. Edit: I cannot simulate KeyPress because I am

How do I make the caret of a JTextComponent skip selected text?

谁说胖子不能爱 提交于 2019-12-05 21:27:57
the normal behaviour of native text fields in many environments is as follows: Textfield with text "abcdefg". I use the mouse to select "efg" from left to right. The caret is now behind "g". When I move the caret to the left by pressing the cursor left key once, the selection is removed and the caret is right before "e". When I do the same in a JTextField or JTextArea (tested on Mac OS) doing the exact same thing results in the caret being right before "g". I know how I could change that programmatically by using a KeyListener and registering it with each component but I am looking for a way

How to get caret position within contenteditable div with html child elements in Internet Explorer

≯℡__Kan透↙ 提交于 2019-12-05 18:03:39
I am working with a contenteditable div that will have the option to have inline html elements such as tags " <p> <font> <br> " in the text flow. At certain points I need to grab the caret position(cursor position) of contenteditable div, the caret(cursor) is after an html child element. i am using following code in javascript for Firefox it works correctly to find caret position(cursor position) of contenteditable div, but i does not find any solution for Internet Explorer to find caret position (cursor position) as window.getSelection is undefined. function getCaretPosition() { if (window

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

喜欢而已 提交于 2019-12-05 17:35:12
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" function places the caret at the end of the div and NOT behind the link that I just replaced sushi with.

WPF PasswordBox Caret

让人想犯罪 __ 提交于 2019-12-05 16:52:16
Is there a way to hide or move the PasswordBox's caret? In .NET 3.5 SP1 or previous, there is no clean way to specify the color of a WPF TextBox/PasswordBox caret. However, there is a way to specify (or in this case remove) that caret from view (via a hack). The caret color is the inverse color of the TextBox/PasswordBox's background color. THus, you can make the background color "transparent black", which will fool the system into using a white caret (which is not visible). The code is (simply) as follows: <PasswordBox Background="#00000000" /> For further information on this issue, please

Native caret position macos cocoa

瘦欲@ 提交于 2019-12-05 14:43:01
I want to be able to get the global caret position inside any application in Mac High Sierra using cocoa or appleScript. I already use NSEvent to get the keyboard and mouse hook but is there a way to get the caret position hook? The caret is different from the mouse position. It moves on key event or mouse click. In windows, you can get the caret position almost anywhere. I want to know if there is the equivalent for macos. I want to show a popup over the text caret, if i type on the keyboard or line return, it moves with the text.I tried getting the position of the key event,