We use MSCE update 16 for a huge project with 100+ custom applications.
These applications are launched by means of the various items on a custom ribbon.
After long searching and tons of trial/error, I managed to create an XML file that configures the ribbon and is loaded at startup by means of the MS_RIBBONXML entry in the configuration file.
Each item should be enabled/disabled and hidden/shown in accordance to the user's permisions and the type of DGN that is loaded.
On startup, the first MDL application is loaded (by means of the MS_DGNAPPS configuration) and that MDL calls mdlCExpression_publishFunction for 2 functions that have an integer as input parameter and return a boolean.
Each item in the XML has the following parameters:
<SyncItemEvent>SystemEvent.FileOpen</SyncItemEvent><Visibility> <ShowExpression>[Session]Session.EvalCExprAsBoolean("checkVisible(x)","myApplication")</ShowExpression> <FeatureAspect>[Session]Session.EvalCExprAsBoolean("checkEnabled(x)","myApplication")</FeatureAspect></Visibility>
Where "x" of course depends on the specific item within the ribbon.
Everything works great except for 1 thing:
The "checkEnabled" function is never called. Not even when checkVisible returns true. I also tried removing the <ShowExpression> entry, but nothing changes.
When configuring "checkVisible" for the FeatureAspect entry, I still get the very same result: the function is not called.
It looks like the <FeatureAspect> is never evaluated.
As usual, I'm quite sure I'm missing something trivial but so far I have no clue.
Hi Robert,
Robert Kock said:Each item should be enabled/disabled
Based on Ribbon definition documentation, I am not sure FeatureAspect relates to enable/disable settings, but it "links" the item to XCommand, defined by particular application. I guess (but not any tests done) when FeatureAspect is not available (every FeatureAspect has own unique ID), the control is not displayed in Ribbon.
But maybe I am wrong...
Witrh regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,
The reason I thought I had to use the FeatureAspect attribute is because in this link https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/212746/how-to-enable-or-disable-menu-items-in-microstation-ce you said:
"A ribbon item definition can contain show expression (show/hide) and feature aspect (enable/disable) conditions. They are evaluated when the ribbon is created or reloaded (which is quite time expensive process). Individual specification, when item is evaluated, can be defined using sync item definition (e.g. to enable icon when an element is selected)."
Something changed in the meantime?
Robert Kock said:Something changed in the meantime?
Well ... yes. My knowledge of the ribbon configuration increased ;-)
From today perspective I think I was wrong at that time (the true is that my list what to test in ribbon definition is still quite long, but I do not plan to reserve time until there is real requirement).
Robert Kock said:Do you know by chance how to enable/disable an item within the ribbon?
When you read ribbon definition (and also Command Framework) documentation, you can find that "Enable Expression" exists.
Also, in ribbon xsd, EnableExpression is defined 4x for different ribbon controls.
Robert Kock said:Preferably with a named expression
You do not share too many details, so it's not clear what mechanism you use to invoke a feature (functionality) related to particular ribbon control.
When you use UserKeyinCommand, you can define <EnableExpression>, e.g. this way (when Named Expresion is used to control enable/disable state):
<EnableExpression>[Session]Session.EvalNEAsBool("<NE name>", true)</EnableExpression>
With regards,
Answer Verified By: Robert Kock
Our ribbon is composed of Tabs, Groups, DropDownButtons and Buttons.
The buttons are always UserKeyinCommands as are the menuitems within the DropDownContent.
So except for the Tabs, we can enable/disable as we like.
Thank you so much.
Robert
Robert Kock said:So except for the Tabs, we can enable/disable as we like.
Why Tab itself should be disabled? It does not make too much sense in my opinion.
Tab can be defined in 2 different ways:
Buttons and DropDownMenuItems are enabled/disabled according to the user's permissions.
A tab should be disabled in case all the items underneath it are disabled.
Nevermind. I'll leave the tab enabled or maybe I'll just hide it.
It's OK this way.
Thank you.
Hello Robert,
I wrote a blog article long ago to discuss similar questions as below:
Sorry it is in Chinese, but fortunately we have so many powerful translation tools at present. Language will be not a barrier to communicating technical questions with each other.