It is almost a year since I started using Zoundry Raven/RavenPlus and I have noticed that there are a handful of quirky behaviours within the editor window. These are not showstoppers. I can still compose and post my blogs successfully, but I find them annoying - a thorn in my side.
Below is just one of these peculiarities in Raven/RavenPlus, and how I fixed it. This problem will only be apparent if the first thing that is done after opening an existing blog post for editing is a drag-and-drop, or when we do a drag-and-drop right after we saved our blog post - the "Save" button on the toolbar remains disabled despite the modification.
Reproducing The Problem
Either open up an existing blog post, or perform a save while editing an existing blog post. Notice that the "Save" button on the toolbar is disabled, as it should.
Select some text - it does not matter how much - or a picture, if there is one. Now perform a drag-and-drop operation on this selection.
Notice that the "Save" button remains disabled even though we have modified our blog post content via a drag-and-drop.
Fixing It
Tracing through the code, I realised that there is no event handler of any kind defined for a drag-and-drop operation in the WYSIWYG editor in Raven/RavenPlus. By referring to the list of events that is fired from the WYSIWYG editor, I could only find one that is related to a drag-and-drop - dragstart. In case you did not know, the WYSIWYG editor in Raven/RavenPlus is actually a Microsoft's Internet Explorer COM object in edit mode.
To fix this problem, what I did is to include an event handler for dragstart (with a function name called Onondragstart) in the class ZMSHTMLControl (class definition starts in line 696) in the file
zoundry\appframework\ui\widgets\controls\advanced\mshtml\mshtmlcontrol.py
Below is the code for the event handler. In effect, it is just one line (and it took me 4 days to figure this out):
def Onondragstart(self): # Document has been modified via a drag-and-drop. Enable the "Save" button. # # Chuah TC 2014 Oct 2 self._fireContentModified() # Onondblclick()
I am not too sure on why there is an extra 'on' in the function names for Internet Explorer active document event handlers - if you happen to know, please do leave a comment below as I am dying to know. All I did was to follow the naming convention in the source code and luckily it works - monkey see, monkey do.
0 comments:
Post a Comment