PeterH_NZ
06-27-2019, 10:08 PM
G'Day
Any of you guys use the FluentUI a lot to build custom menus, and experienced synchronisation problems when using Custom Undo actions?
What I mean by this, is that it is reasonably easy to keep your FluentUI menu options in the correct state (enabled or disabled via each menu options _getEnabled method).
Here's a very simple example, a menu with two options:
1. Add a picture
2. Delete a picture
For simplicity if the picture already exists then it is replaced, so the Add a picture menu option is always enabled.
So when you initialise the menu the Delete pictures _getEnabled callback procedure is invoked:
Public Sub FUI_AddPicture_getEnabled(ByVal control As IRibbonControl, _
ByRef isEnabled As Variant)
isEnabled = True
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
Public Sub FUI_AddPicture_onAction(ByVal control As IRibbonControl)
CodeToAddAPicture
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
Public Sub FUI_DeletePicture_getEnabled(ByVal control As IRibbonControl, _
ByRef isEnabled As Variant)
If PictureExists Then
isEnabled = True
else
isEnabled = False
End If
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
Public Sub FUI_DeletePicture_onAction(ByVal control As IRibbonControl)
CodeToDeleteAPicture
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
So after the user adds or deletes a picture the FluentUI ribbon is reset and the "Delete a picture" menu option is enabled or disabled accordingly. So far, so good.
But lets say we want to add Custom undo actions to both menu options, so that the user has a nice friendly way to undo what they have just done rather than see a truckload of incomprehensible VBA operations in their Undo list. This works just great, but this is where the problem with the FluentUI menu synchronisation starts, as soon as you Undo either an "Add a Picture" or "Delete a picture" operation, the "Delete a picture" menu is in the opposite state of what it should be. The problem occurs because when Word undoes the VBA operations it does not cause the FluentUI menu to be reset, it only Undo(es) those operations which directly affect the document (it does undo Document Variable adds, delete, updates either [and a bunch of other things]) .
Does anyone know of a workaround for this???
Thanks - Peter
Any of you guys use the FluentUI a lot to build custom menus, and experienced synchronisation problems when using Custom Undo actions?
What I mean by this, is that it is reasonably easy to keep your FluentUI menu options in the correct state (enabled or disabled via each menu options _getEnabled method).
Here's a very simple example, a menu with two options:
1. Add a picture
2. Delete a picture
For simplicity if the picture already exists then it is replaced, so the Add a picture menu option is always enabled.
So when you initialise the menu the Delete pictures _getEnabled callback procedure is invoked:
Public Sub FUI_AddPicture_getEnabled(ByVal control As IRibbonControl, _
ByRef isEnabled As Variant)
isEnabled = True
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
Public Sub FUI_AddPicture_onAction(ByVal control As IRibbonControl)
CodeToAddAPicture
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
Public Sub FUI_DeletePicture_getEnabled(ByVal control As IRibbonControl, _
ByRef isEnabled As Variant)
If PictureExists Then
isEnabled = True
else
isEnabled = False
End If
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
Public Sub FUI_DeletePicture_onAction(ByVal control As IRibbonControl)
CodeToDeleteAPicture
' This simply invalidates all of the ribbons controls
ResetRibbon
End Sub
So after the user adds or deletes a picture the FluentUI ribbon is reset and the "Delete a picture" menu option is enabled or disabled accordingly. So far, so good.
But lets say we want to add Custom undo actions to both menu options, so that the user has a nice friendly way to undo what they have just done rather than see a truckload of incomprehensible VBA operations in their Undo list. This works just great, but this is where the problem with the FluentUI menu synchronisation starts, as soon as you Undo either an "Add a Picture" or "Delete a picture" operation, the "Delete a picture" menu is in the opposite state of what it should be. The problem occurs because when Word undoes the VBA operations it does not cause the FluentUI menu to be reset, it only Undo(es) those operations which directly affect the document (it does undo Document Variable adds, delete, updates either [and a bunch of other things]) .
Does anyone know of a workaround for this???
Thanks - Peter