Word for Windows plugin: text selections display incorrectly
I reported this earlier as a Juris-M problem, but it actually seems to be an issue with the .dotm plugin for Word for Windows that comes with Zotero standalone, at least in Word 2013 under Windows 10.
What's happening is that when the plugin is enabled (even if there are no Zotero fields in the document), text that the user selects with the mouse or keyboard is no longer consistently highlighted: it's still selected, as can be verified by changing the font or copy and pasting it, but its gray background disappears as does the floating formatting toolbar that normally appears. So there is no visual cue to the selection, which is a huge annoyance when using Word.
This seems to be a side-effect of the work the plugin is doing in the background every time the selection is changed (it reads the selection range and checks for Zotero fields, among other things). I've found a way of fixing it by turning screen updating off and back on in the UpdateRibbon class event handler, which fires every time the selection changes:Private Sub UpdateRibbon()
If Not initialized Then
Exit Sub
End If
On Error GoTo ErrHandler
Application.ScreenUpdating = False ' Stop redrawing the window
Dim isCitation As Boolean
Dim isBibliography As Boolean
Call getZoteroFieldAtSelection(isCitation, isBibliography)
Dim hasFields As Boolean
hasFields = documentHasZoteroFields()
If isCitation <> selectionIsCitation Or _
isBibliography <> selectionIsBibliography Or _
hasFields <> documentHasFields Then
selectionIsCitation = isCitation
selectionIsBibliography = isBibliography
documentHasFields = hasFields
ribbonUI.Invalidate
End If
ErrHandler:
ThisDocument.Saved = True
Application.ScreenUpdating = True ' Let the window update again
End Sub
I don't know if this is a good, let alone the best, way to address the problem (does this much work need to be done every time the selection changes, even if there are no Zotero fields in the document?), but it may help isolate the issue.
-
Bruce RuskJust an update to say that this bug is still present in Word 2016.
-
adamsmithI'd expect the latest version of Standalone/the Word plugin (3.5.2) to have fixed this. Not sure if that's packed as juris-m already, though
-
Bruce RuskAh... somehow the update to Juris-M (which does have the newest plugin) didn't update the plugin in my Word startup folder. Did that manually and it's working great.