Event for detecting "Complete Word"

SyntaxEditor for WPF Forum

Posted 9 months ago by Daisuke Nakada
Version: 18.1.0673
Avatar

Hi,

Is there an event or some way that can detect when "Auto-Commit Without Showing a Popup (Complete Word)" occurs?

Thank you.

Comments (9)

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

When any completion item is committed to be inserted into the text, a text change of type TextChangeTypes.AutoComplete will be performed.  However it doesn't differentiate between whether the popup had showed and an item was chosen, or whether a single item fully matched and was inserted without a popup.

I'm not sure there's a way to detect that.  May I ask why you needed to know?


Actipro Software Support

Posted 9 months ago by Daisuke Nakada
Avatar

Thank you for your response.

In my application, a code snippet is inserted when the completion list is commetted. In order to achieve that, I wrote some code in the completion session's Committing event handler. In this code the completion session is canceled and it's equivalent code snippet is inserted.

I wrote this code several months ago but recently I found that the code snippet is not inserted when commetted WITHOUT popups (because the event does not occur, of course.) Should I have written all those code in the IEditorDocumentTextChangeEventSink.NotifyDocumentTextChanging event handler?

Thank you.

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Actually the CompletionSession.Committing event should be getting raised, even when the completion list popup doesn't show and a single item fully matches to insert it.  You aren't seeing that?  It runs through the same Commit method that pressing Tab does when the user selects an item and that Commit method does raise that event.


Actipro Software Support

Posted 9 months ago by Daisuke Nakada
Avatar

Sorry, I was wrong. What is not raised is not the Committing but the Opened.

Also, there was something wrong in my code on how to attach the Committing event handler. In the RequestSession method, I only attached the Opened event handler and within it I attached the Committing event handler. So no Committing event handler was attached when committed without a popup because the Opened event never got raised.

Thank you for your help!!

Posted 9 months ago by Daisuke Nakada
Avatar

I have one more question.

When committed without a popup, the Opened event does not occur but the Closed event does. Is that correct?

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hmm, that's a good observation.  When it auto-commits from a single match, it ends up bypassing the area of code that raises the Opened event.  However the session is technically open (IsOpen = true) for a brief instant, even though no popup displays.  

How do you think it should behave event-wise if the popup never shows?  Should we still raise the Opened event since the session logic is occurring, and then have it immediately commit and raise Closed right after in that scenario?  Maybe that is the most consistent way to do it?


Actipro Software Support

Posted 9 months ago by Daisuke Nakada
Avatar

Both behaviors sound OK to me if we can clearly know when those events occur (and when not) through the Actipro WPF Studio Documentation.

Even when commetted withouth the popup, the Opened event can occur because the CompletionSession.Open method has been called. Or, from a different viewpoint, the Opened event doesn't have to occur because the popup hasn't got opened even though the session has got opened (for a brief instant of time.)

In my opinion, it'll be a little better that the Opened event occurs because I believe the Opened/Closed events should always be paired.

Answer - Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Thank you for the feedback.  We are adding the Opened event so that there is a proper pair, even when the popup doesn't show.  This is good since the Open/Close pair is really meant to be for the session itself, and not necessarily a popup.  Although the two generally go hand-in-hand.


Actipro Software Support

Posted 9 months ago by Daisuke Nakada
Avatar

Yes, I think it better and more natural too.

Thank you for your support!

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.