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
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
ThisDocument.Saved = True
Application.ScreenUpdating = True ' Let the window update again
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.