VS 2010 mouse processor extension - not working

后端 未结 3 752
北海茫月
北海茫月 2021-01-19 02:26

I am experimenting with a Visual Studio 2010 extension, where I need to work with the events exposed by IMouseProcessor.

As far as I can tell from the docs, I should

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-19 03:07

    It took me a while to find the complete solution to this problem, so I will post the complete solution here:

    1. As suggested by 280Z28, there is a bug in the SDK for Beta 2. You need to edit the .csproj manually to ensure that your assembly is included in the generated VSIX file.
    2. As JaredPar answered, the TextViewRole attribtute should be added to the IMouseProcessorProvider implementation.
    3. Lastly, the IMouseProcessorProvider should also be decorated with a Name attribute.

    All in all, this code works:

    [Export(typeof(IMouseProcessorProvider))]
    [ContentType("code")]
    [TextViewRole(PredefinedTextViewRoles.Editable)]
    [Name("mouseproc")]
    internal sealed class MouseProcessorFactory : IMouseProcessorProvider
    {        
        public IMouseProcessor GetAssociatedProcessor(IWpfTextView wpfTextView)
        {            
            return new MouseProcessor();
        }
    }
    

提交回复
热议问题