We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Getting TextPosition / Word under cursor

Thread ID:

Created:

Updated:

Platform:

Replies:

131425 Jul 8,2017 02:31 AM Jul 28,2017 08:31 AM WPF 3
loading
Tags: SfRichTextBoxAdv
Kyle Steven Lewis
Asked On July 8, 2017 02:31 AM

Hi,

I am converting a lot of some interface over from standard old RichTextBox to your SfRichTextBoxAdv, but I'm having an issue with a function.

I currently execute:
Point nMousePositionCoordinate = Mouse.GetPosition(contentRTB);
TextPointer cursorPosition = contentRTB.Document.GetPositionFromPoint(nMousePositionCoordinate, false);
string frontChunk = cursorPosition .GetTextInRun(LogicalDirection.Backward);
string frontChunk = cursorPosition .GetTextInRun(LogicalDirection.Forward);

I can't seem to find a way to get a HierarchalPosition to use contentRTBAdv.Document.GetTextPosition() or anything in that realm.  Any help getting a position from mouse location or just the word under the mouse would be super helpful, thank you.



Venkatesan Mani [Syncfusion]
Replied On July 10, 2017 08:06 AM

Hi Kyle Steven Lewis,

Thank you for using Syncfusion products.

At present, there is no API to get the text position from the mouse point in SfRichTextBoxAdv control. We will consider your requirement as feature request and logged a feature request. We will implement this feature in our upcoming Essential studio 2017 Volume 3 release which will be available by end of July 2017. We request you to visit our website periodically for feature related updates.

Now as a workaround, we can raise the mouse down and up event manually in SfRichTextBoxAdv to update the text position at the mouse point. We can move the selection start and end text position to word start and end respectively. For more information about the text position methods, please refer our API documentation link below,
https://help.syncfusion.com/cr/cref_files/wpf/sfrichtextboxadv/Syncfusion.SfRichTextBoxAdv.WPF~Syncfusion.Windows.Controls.RichTextBoxAdv.TextPosition_methods.html

Then we can get the text from the selection instance. Finally, we can reset the cursor again to user editing position. We have prepared a sample to demonstrate the same. please find the sample from the following link,

Sample link:
Sample.zip.

Note: We have triggered the mouse events manually within a preview mouse move event. So, there will be noticeable delay exist in getting text on mouse move.

We are suspecting that you are trying to achieve a code editor something like. If so you can try our WPF EditControl. For more information, please refer the following UG link,
https://help.syncfusion.com/wpf/syntaxeditor/overview

Disclaimer: The date for the feature implementation is tentative and not a commitment on our parts. It may be subjected to change.

Regards,
Venkatesan M. 


Kyle Steven Lewis
Replied On July 27, 2017 10:52 PM

I do like the syntax highlighting of the edit window, I just don't like how it lacks the spell checking of the SfRichTextBoxAdv, the red squiggle spell error part to be exact.  Essentially I just need to have a custom popup window appear when hovering over certain key words without having the text cursor move there.  I understand doing it on mouse move, I mean I could even set a timer to only have it happen every 2 seconds to check, I was just curious if it could be done without moving the text cursor.Thank you for submitting my suggestion.

Venkatesan Mani [Syncfusion]
Replied On July 28, 2017 08:31 AM

Hi Kyle Steven Lewis,

Thank you for your suggestions.

As we mentioned in our previous update, we have considered API to get the text position from the mouse point in SfRichTextBoxAdv control. We will let you know once it is implemented. We request you to visit our website periodically for feature related updates.

Our SfRichTextBoxAdv supports API to spellcheck a word and return list of suggestions if the word at the given text position is misspelled. Please refer our API documentation for more information.

API reference link:
https://help.syncfusion.com/cr/cref_files/wpf/sfrichtextboxadv/Syncfusion.SfRichTextBoxAdv.WPF~Syncfusion.Windows.Controls.RichTextBoxAdv.SfRichTextBoxAdv~GetSpellingError.html

Regards,
Venkatesan M. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;