[Idle-dev] Extensions overriding EditorWindow methods
taleinat at gmail.com
Sun Jan 28 16:15:50 CET 2007
I'm close to finishing an initial version of a search bar for IDLE which
implements incremental searching.
I'm writing it as an IDLE extension, so that it can be turned on or off by
each user as he likes, through the extensions config. For this I need a way
to hook onto EditorWindow's find_event(), find_again_event(), ... methods.
An extension's constructor receives the EditorWindow instance, so overriding
the methods is easy. However, EditorWindow binds its methods to events in
its constructor, so overriding an instance's methods doesn't change the
method called by the event binding mechanism.
English translation - overriding doesn't work, I need to rebind the relevant
events to new functions/methods.
1) Rebind the events to new handlers in the extension's constructor
Ugly? Code duplication...
2) Bind all events to a virtual handler, which calls the instance's
currently bound appropriate method
Cleaner but more complex, this is actually duplicating the functionality of
the event binding mechanism!
I was leaning towards 2 but am now thinking 1 is better, since it's simpler
and more consistent.
Any thoughts on this? Any other, better solutions?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IDLE-dev