locked
How to set the Visibility Contexts for the text editor RRS feed

  • Question

  • I have few commands are added to the main edit menu.
    I'm trying to set context for those commands in the .vstc file in VisibilityItem to
    UICONTEXT_CodeWindow hoping that command will only be applicable when
    user opened the editor window (html, aspx, xaml, cs). That doesn't seem to have any
    effect and commands don't show up at all.

    Sunday, July 18, 2010 1:22 PM

Answers

All replies

  • Hi Sir,

    I guess you have edited the VisibilityConstraints section in .vstc file as the example

    <VisibilityConstraints>
      <VisibilityItem guid="cmdSetGuidMyProductCommands"     id="cmdidAddWidget"
        context="guidNotViewSourceMode"/>
    </VisibilityConstraints>

    Which can reference to VisibilityConstraints Element.

    And you choosed to set the context as "UICONTEXT_CodeWindow".

    If you did so, and it doesn't work.

    I suggest to try "GUID_TextEditorFactory" instead of the current context "UICONTEXT_CodeWindow".

    If the commands remain not to show up, be free to let me know.

    Regards,

    /Victor

    Monday, July 19, 2010 6:48 AM
  • Hi Victor,

    I did tried to use with the UICONTEXT_CodeWindow, It doesn't work.
    The GUID_TextEditorFactory option works fine only for files with the .txt extention, but dosen't work with are aspx, xaml, cs files.

     

    Thanks,

    Igor

     

    Tuesday, July 20, 2010 7:33 AM
  • Hi Igor,

     

    Thanks for your reply.

    But I'm afraid if you want it support aspx, xaml, cs files, <VisibilityConstraints> may not enough to meet your requirement.

    You may use OleMenuCommand.BeforeQueryStatus Event to implement it, which can reference to:

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.olemenucommand.beforequerystatus(VS.80).aspx

     

    And I really recommend this post, which has the same question as yours and detailed sample code:

    http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/f3acc18c-b176-4f06-a8d1-cccff3d4bf7f/

     

    Hope this can help and looking forward to your reply.

     

    Best Regards,

    Ziwei Chen

     

    • Marked as answer by IMDL Friday, July 23, 2010 12:03 PM
    Wednesday, July 21, 2010 3:35 AM
  • Hi Igor,

     

    Thanks for your reply.

    But I'm afraid if you want it support aspx, xaml, cs files, <VisibilityConstraints> may not enough to meet your requirement.

    You may use OleMenuCommand.BeforeQueryStatus Event to implement it, which can reference to:

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.olemenucommand.beforequerystatus(VS.80).aspx

     

    And I really recommend this post, which has the same question as yours and detailed sample code:

    http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/f3acc18c-b176-4f06-a8d1-cccff3d4bf7f/

     

    Hope this can help and looking forward to your reply.

     

    Best Regards,

    Ziwei Chen

     

    Hi Victor,

    Thanks for your reply.
    If I understands rights that I can't play with visibility before my package is loaded?

    Thursday, July 22, 2010 4:47 PM
  • Hi Igor,

    Thanks for your post again.

    If you would like to choose this method, the package should be loaded first.

    As far as I know, it's unlikely to set visibility before package loaded, and it's the best way to achieve your goal.

    However, I'm sorry if my solution does not meet your requirement completely.

     

     

    Best Regards,

    Ziwei Chen

     

    • Marked as answer by IMDL Friday, July 23, 2010 12:03 PM
    Friday, July 23, 2010 1:39 AM