Dreamstime

Monday, 19 January 2015

RavenPlus: Find (& Replace) And The "Save" Button

The "Find and Replace" Dialog box in Raven/RavenPlus

I think this is the second last oddity that I have encountered with the "Save" button in the editor window in Raven/RavenPlus. Even though modifications have been made to the blog post via a "Find and Replace", the "Save" button remains disabled if it was disabled previously. The workaround here is similar to the Spell-Checking problem i.e. we fire an "onkeypress" event back into the editor.

The Source Code

We only need to modify just one file to fix this problem:

zoundry\appframework\ui\widgets\controls\advanced\mshtml\mshtmlfindreplacectx.py

There is only one class in this file: class ZMshtmlEditControlFindReplaceTextContext. The code in RED below is the modifications that I have made in this class to fix this problem.

====== BEGIN ======



def __init__(self, mshtmlEditControl, initialText):
ZBaseEditControlFindReplaceTextContext.__init__(self)
self.mshtmlEditControl = mshtmlEditControl
self.initialText = initialText
self.findRange = None
self.currRange = None
self.ieWord = None

# Made the variable "mshtmlBodyDispElement" local within this class -
# we will need it at "_replaceText" to fire a "onkeypress" event into
# the MSHTML.Body element.
# Chuah TC : 2014 Nov 16
self.mshtmlBodyDispElement = None

# end __init__()




def _reset(self):
# Appended "self." to "mshtmlBodyDispElement" in this function.
# Chuah TC : 2014 Nov 16


self.mshtmlEditControl.selectNone()
doc = self.mshtmlEditControl._getMshtmlControl().getIHTMLDocument()
self.mshtmlBodyDispElement = getDispElement(doc.body)
self.findRange = self.mshtmlBodyDispElement.createTextRange()
self.currRange = None
# end _reset()




def _replaceText(self, textRange, replaceText):
if textRange and replaceText is not None:
textRange.text = replaceText

# Chuah TC : 2014 Nov 16
# Fire an "onkeypress" event to MSHTML.Body element
# to enable the "Save" button on the editor's toolbar.
self.mshtmlBodyDispElement.FireEvent("onkeypress")

# end _replaceText



====== END ======













2 comments:

  1. hi i want to mass publish my post, how i can do that with zoundy...
    thanks for your developing

    ReplyDelete