Re: Orca overriding a method?



Hi Joanie,

Generically speaking, how does one override a method? In looking over
the existing scripts, it *seems* like you simply (re)define your method
within your script and your redefined method gets used instead of the
one in default.py, but since that's not actually working for me.... :)

Specifically speaking, I noticed that Insert+F doesn't identify text
that is bold within Openoffice.org. Since weight seems to be the
relevant text attribute, I thought I'd experiment to see if I could
cause that information to be announced -- but only when Insert+F is
pressed in StarOffice/OOo. I tried defining readCharAttributes in
staroffice.py, but through a little debugging code I see that my
readCharAttributes is being ignored in favor of the one in default.py.
I'm not creating a new event handler and/or key binding, right???

You need to add a new input event handler as well. The following diff to the
current StarOffice.py script does what you are looking for. You will need
to flesh out the new readCharAttributes() method. At the moment, it
just calls the one in the super class.


Index: StarOffice.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/scripts/StarOffice.py,v
retrieving revision 1.44
diff -u -r1.44 StarOffice.py
--- StarOffice.py       12 Sep 2006 12:48:59 -0000      1.44
+++ StarOffice.py       17 Sep 2006 01:12:37 -0000
@@ -238,6 +238,11 @@

        default.Script.setupInputEventHandlers(self)

+        self.inputEventHandlers["readCharAttributesHandler"] = \
+            input_event.InputEventHandler(
+                Script.readCharAttributes,
+ _("Reads the attributes associated with the current text character."))
+
        self.inputEventHandlers["speakInputLineHandler"] = \
            input_event.InputEventHandler(
                Script.speakInputLine,
@@ -452,6 +457,10 @@
        allLabels = util.findByRole(panel, rolenames.ROLE_LABEL)
        for i in range(0, len(allLabels)):
            self.speakSetupLabel(allLabels[i])
+
+    def readCharAttributes(self, inputEvent=None):
+        print "StarOffice.py: readCharrAttributed called."
+        default.Script.readCharAttributes(self, inputEvent)

    # This method tries to detect and handle the following cases:
    # 1) Writer: text paragraph.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]