One-way conversion means:
-
The menu properties that are dynamically set will be reflected in the ribbon bar.
-
However, the ribbon bar properties that are dynamically set will not be reflected back in the original menu.
Following uses an example to show how one-way conversion may affect the code logic and the developer should take this into consideration.
Phenomenon:
After enabling a menu item via the ReplaceCategoryByXml or ReplaceCategoryByJSON method, it is found that the Clicked event of the menu item in the ribbon bar cannot be triggered.
Reason:
If the menu item is disabled by default, even by customizing and setting the enabled property to true, its clicked event still cannot be triggered in the ribbon bar.
For example:
When the first sheet window or the default MDI Frame window is opened, the enabled property of the Undo menu item (m_undo) is set to false by default.
When you open the third sheet window and use the ReplaceCategoryByXML or ReplaceCategoryByJSON method to customize a category (such as Edit), and set the enabled property of the Undo button to true, although the Undo button in the ribbon bar is enabled, the enabled property of the original Undo menu item (m_undo) is still false. Therefore, the Clicked event of the original Undo menu item (m_undo) cannot be triggered.
Solution:
-
#1: Set the enabled property of the original Undo menu item (m_undo) to true in the script. This ensures that the clicked event of the Undo button in the ribbon bar can be triggered normally.
-
#2: When using the ReplaceCategoryByXml or ReplaceCategoryByJSON method to customize the corresponding Undo button, define a clicked event for the button at the same time.