How to customize the intelliprompt with a textbox

SyntaxEditor for WPF Forum

Posted 12 years ago by Nassim Farhat
Version: 11.2.0551
Avatar
Hello,

I would like to customize an intelliprompt completion list by adding an element at the end of the list that would be a "textbox" control where i can type in a new item. When enter is pressed, this new item will go through a validation step, if fails, a red message should popup, if pass, the newly typed item should be dropped into the document (same as selecting a normal item from the completion list). Is this an easy task to accomplish?

Nassim F.

Comments (14)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nassim,

We haven't tried anything like that but it may be possible. The CompletionSession.CreatePopupContent method by default will create an instance of a IntelliPromptCompletionList control to display in a popup. You could retemplate that control and inject your TextBox in there. I'm not sure if you would run across any focus/typing issues but as long as your TextBox accepts focus, it may work ok.


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
Thanks for your reply,
As I'm kind of new to WPF I was wondering how to reference the intelliprompt completion list in the XAML code. I've been reading online a little and I think that i need to get a hold of the Control Templates/XAML declarations for the actipro intelliprompt completion list control so that i can try retemplating it with a texbox as the last element? If so, how can i reference this in my XAML code? Maybe something similar to:

<ControlTemplate x:Key="MyIntellipromptCompletionList" TargetType="{x:Type ??<the actipro intelliprompt completion list control>??}">
    ...
</ControlTemplate>
Do I need to add a special namespace in the header of the XAML file in order to reference your template correctly? Do you have examples of doing such things?

Thank you for your help
Nassim

[Modified at 12/20/2011 08:58 AM]
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nassim,

Is your company licensed to use the WPF SyntaxEditor, either standlone or via WPF Studio? If you are a WPF Studio customer, the default styles/templates are downloadable from your account.


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
Thanks for your reply, we're licensed for WinForm SyntaxEditor, but we would like to evolve to WPF, except that i am required to make some small test demos for my supervisor. One of these demos would be... as mentionned above to customize the completionList so that a texbox appears at the end of the list of items.

So far, I've only installed the 30day trial version of WPF SyntaxEditor, so is there a way for you do give me access to those templates, or atleast the completionList template so that i can complete my demo? If things go well, I'm pretty sure that we'll be buying a license.

regards
Nassim
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok, we'll email you the template for the completion list.


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
Thanks, I ll take a look at it and reply to you if i find more issues.

Nassim
Posted 12 years ago by Nassim Farhat
Avatar
Thank you so much, I did as you said:

"I cloned the style that targets it and put the cloned/modified version in my Application.Resources."

now I am showing up what i want to show up when the intelliprompt completion list opens. So to recap, on completionlist popup I have a control that looks like:
1-The intelliprompt
2-Docked on the bottom I have a TextBlock
3-Docked on the bottom of that I have a ComboBox.

Q1-
My comboBox contains a list of items but when i try to select them I get nowhere since i can't get the focus. Do you know how I can get the focus in the combobox?

Q2-
In the case that i cannot get the focus, I was thinking about adding a shortcut key like Shift+Enter or something to create a new element for the list based on the "TypedText" property. Do you know how i can dedicate a hotkey for that purpose, maybe overwrite some editor hotKeys that i'm not using and have it do what I want instead??

Thanks
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nassim,

I believe we have an OnPreviewMouseUp override in our IntelliPromptCompletionList class that will focus back to the view when it's hit. That ensures that the caret remains blinking when items are clicked.

If you need to disable that behavior you could probably override that class and method and don't call the base class (or call it only in certain instances). You'd also need to override the CompletionSession.CreatePopupContent method to create an instance of your customized IntelliPromptCompletionList-based class instead of using our default code there.


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
Thank you for your response.

I succeeded in doing what you mentioned and i'm now able to keep the focus correctly within my retemplated IntellipromptCompletionList control.

Within that control I injected a Label and under that a dropdown with 4 items but no items preselected.

When i open the intelliprompt and click on the label the intelliprompt does not disappear. But when i try selecting with the mouse items in the combobox, the intelliprompt automatically disappears. Any ideas what can cause that behaviour and how to fix it?

I even tried to hookup to the OnLostFocus override of my CustomIntellipromptCompletionList control but it never fired when the control disappeared. I thought maybe i could cancel the event but nothing.

Regards
Nassim
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nassim,

Sorry but I'm not really sure what is doing it. In your custom IntelliPromptCompletionList, perhaps look up the visual tree to get the popup and attach to its closing event. Then break on that and see what the call stack is that is closing it.


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
hi and thanks for your reply.

I kind of gave up on adding the combobox, since it was too difficult to play with the combobox items because of the completionlist disappearing and all.

Anyways, i simplified the whole thing and simply added a textbox and a button next to it. Now i hooked up all my events and I want to accomplish the following:

In the textbox, the user can press text that does not appear in the list of items of the completionlist (so far this works). I call the Session.Close on Enter pressed, but i am unable to return the text that was typed in the textbox BACK to the editor.

I tried adding an item to the items collection and selecting it before i close the intelliprompt but nothing, i think when the session is already opened, these things are set in stone! So can you help me and tell me how to return my desired text back to the editor?

Thanks
Nassim
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Nassim,

Can't you just call something like this from the completion session when you press Enter in your scenario?
this.View.SelectedText = "yourtext";
this.Cancel();


Actipro Software Support

Posted 12 years ago by Nassim Farhat
Avatar
ya that worked nicely.

thanks for the heads up.

I actually found how to avoid closing my intelliprompt on lost focus (as i was mention edbefore when my mouse was over the combobox elements, the intelliprompt would close).

Basically I overrided the following in the CompletionSession object
public override bool ClosesOnLostFocus
        {
            get
            {
                return false;
            }
        }
it now returns false and solves my problems.

Thanks for your help.

[Modified at 01/17/2012 04:33 PM]
Posted 11 years ago by MSR-Solutions GmbH - IT - MSR-Solutions GmbH
Avatar

Hello,

we're licensed to use the WPF SyntaxEditor and need to customize the intelliprompt completion list as well. Could you please email us the template too?

 

Thanks

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.