none
Outlook 2010/2013 - custom Context Menu becomes disabled if all entries are disabled RRS feed

  • Question

  • Hi,

    Custom context menu created with following sample displays disabled Addin Menu.

    This behavior looks strange for me. Can anyone explain why does it behave like this, and how can I display menu with disabled buttons?

    Sample code

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
     <contextMenus>
      <contextMenu idMso="ContextMenuMailItem">
       <menu id="addinMenu" label="Addin Menu" visible="true" enabled="true">
        <button id="addinButton" enabled="false" label="Addin Action" visible="true" />
       </menu>
      </contextMenu>
     </contextMenus>
    </customUI>

    Result:



    EDIT:
    Maybe providing some context, will help to get an answer:
    What I need, is a context menu with 2 actions that are not always enabled. Sometimes 2 actions will be available, sometimes 1 action, sometimes none. I want to use getEnabled attribute to achieve that.
    What I also want, and this is important for me, is that all action buttons have to be always visible, whether they are enabled or not. 
    Everything works fine, except situation when all actions are disabled, which makes whole menu disabled, and the menu does not expand.



    • Edited by kar0l Thursday, February 13, 2014 9:07 AM give more details to the question
    Wednesday, February 12, 2014 4:16 PM

Answers

  • Thanks for your answers, so I understand this is by design.

    I still want that behavior, cause it was possible to achieve in Outlooks 2007 and 2010 with the command bars object model.

    And I managed to achieve what I want with dynamicMenu control :)

    Here is the code for MailContextMenu.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
     <contextMenus>
      <contextMenu idMso="ContextMenuMailItem">
       <dynamicMenu id="addinMenu" label="Addin Menu" getContent="GetContextMenuContent"/>
      </contextMenu>
     </contextMenus>
    </customUI>

    and for MailConetxtMenu.Content.xml which is loaded in GetContextMenuContent callback:

    <menu xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
      <button id="addinButton"
              label="Addin Action" onAction="AddinButtonAction" enabled="false" />
    </menu>
    And the result:


    • Marked as answer by kar0l Thursday, February 13, 2014 3:57 PM
    • Edited by kar0l Thursday, February 13, 2014 4:03 PM
    Thursday, February 13, 2014 3:56 PM

All replies

  • Try changing the XML for the context button as follows and see how it looks then:

     <button id="addinButton" enabled="true" label="Addin Action" visible="true" />


    Ken Slovak MVP - Outlook

    Wednesday, February 12, 2014 6:22 PM
    Moderator
  • Hi,

    Welcome to MSDN forum.

    According to my investigation, this behavior is by design.

    If I add a new enabled button:

    <button id="addinButton1" enabled="true" label="test" visible="true" />

    The menu would be enabled and we could find buttons under the menu:

    If I enabled the button named ‘test’, the menu would be disabled again as the figure you provided.

    From my understanding, Outlook will disabled the menu if there is no enabled button under the menu. So there is no way to display the disabled button if there is only one button under the menu.

    As a workaround, I only found we could add a new button with blank text like this:

    <button id="addinButton1" enabled="true" label=" " visible="true" />

    The disabled button would be displayed:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 13, 2014 9:05 AM
    Moderator
  • Ken, 

    Changing button to enabled is not an answer to my question. It would change the assumptions and whole case. Button have to visible and disabled.  


    Thursday, February 13, 2014 9:06 AM
  • In that case I'd use George's solution, a dummy button with a blank caption that's always enabled. Otherwise if your menu has no buttons enabled the menu itself will be disabled.

    Ken Slovak MVP - Outlook

    Thursday, February 13, 2014 3:34 PM
    Moderator
  • Why do we need to invent a wheel if the things work properly?

    It is expected to find the menu disabled if all items can't be reached/clicked. It is just by design :) 

    Thursday, February 13, 2014 3:38 PM
  • It's easy enough to use the suggested workaround and keep to the spec, if that's what's wanted.

    Ken Slovak MVP - Outlook

    Thursday, February 13, 2014 3:49 PM
    Moderator
  • Thanks for your answers, so I understand this is by design.

    I still want that behavior, cause it was possible to achieve in Outlooks 2007 and 2010 with the command bars object model.

    And I managed to achieve what I want with dynamicMenu control :)

    Here is the code for MailContextMenu.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
     <contextMenus>
      <contextMenu idMso="ContextMenuMailItem">
       <dynamicMenu id="addinMenu" label="Addin Menu" getContent="GetContextMenuContent"/>
      </contextMenu>
     </contextMenus>
    </customUI>

    and for MailConetxtMenu.Content.xml which is loaded in GetContextMenuContent callback:

    <menu xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
      <button id="addinButton"
              label="Addin Action" onAction="AddinButtonAction" enabled="false" />
    </menu>
    And the result:


    • Marked as answer by kar0l Thursday, February 13, 2014 3:57 PM
    • Edited by kar0l Thursday, February 13, 2014 4:03 PM
    Thursday, February 13, 2014 3:56 PM
  • Hi Kar0l,

    Thanks for your solution.

    From my understanding, Outlook would only check the XML for loading the menu. If we create the menu item in .Net runtime, the check has no effect.

    In addition, thank Eugene for the link, I found the related information from your links.

    It would be userful if other community members are faced with the same question.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 14, 2014 3:49 AM
    Moderator