Leo's trunk now contains several changes to the rClick.py plugin.

The initial reason for the changes was that right-clicking in the log
pane crashed.

What I did:

1. Moved the rClickBinder and rSetupmenus top-level functions into the
ContextMenuController class.

This eliminates the need to register some event handlers.  In fact,
rSetupmenus wasn't being called, perhaps as the result of recent
changes to events.

2. Used the after-create-leo-frame to fire the onCreate handler.

3. I left the rClicker callback as a top-level event handler because
we want to register this just once.  Putting this event handler in the
controller class would be possible, but that would just generate lots
of events, and rClicker would have to check that c (from the keywords
dict) matches self.c.  In this case, using a single callback is
simplest.

At present, rClicker doesn't actually need to know the
ContextMenuController instance for c, but it would not be a problem if
it did.  At the top level we would define:

controllers = {}

The ctor for the ContextMenuController class would do:

global controllers
controllers [self.c] = self

And rClicker would do:

global controllers
cc = controllers.get(c)

I am going into detail with this pattern because the pattern is a
general way of eliminating almost all globals in plugins.  We simply
put almost all data in the plugin controller.  Top-level callbacks get
the proper controller as shown.

To repeat: we often want to register event handlers just once, and let
the event handler determine the proper controller as shown.  The event
handler can then call a corresponding method in the controller.

This encapsulates almost everything in the controller class.  In
addition, it minimizes the number of event handlers that need to be
registered.

I am not yet satisfied with the rClick.py plugin.  It's probably good
enough to put in b3, but I would like the following improvements:

1. Move almost all code into the ContextMenuController class.  Imo,
the init, onCreate and rClicker functions are the only code that
should be at the top level.

2. I still do not understand what @popup <name> does.  Apparently,
<name> is the name of a menu.  Can we associate different popup menus
with different panes?  If so, how?

I think one or two fairly simple examples of @popup trees would reduce
my confusion considerably.

Edward

P.S.  The create-optional-menus event typically no longer gets
generated.  If this is a problem for rClick.py some workaround will
have to be devised.  My impression, however, is that the user already
has enough ways to customize menus.

EKR
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to