On Wed, Oct 1, 2008 at 2:37 PM, zpcspm <[EMAIL PROTECTED]> wrote:

> Since it is not possible to return the user input from this function,
> I have tried the opposite way. I have tried to pass another function
> to getInput() as argument, a function that would accept k.arg as
> argument and would actually do something...

Interesting idea.  It may be better than the strategy that I used in
leoEditCommands.py, which was basically to create a new state handler
for each different command.

> This didn't work as well. Investigation of the leo source code stopped
> at [snip]
> if handler: handler(event)

> So it looks that the interaction with the handler is hardcoded. I
> can't have a getInput() function with more arguments.

But you can.  The trick is to bind the arguments before calling your
generalized handler.

def myCommand(whatever):

    def handler(event, arg1=arg1, arg2=arg2,...):
        << do what you want with the args >>

    getInput(handler)

In essence, this is lambda binding.

HTH.

Edward

--~--~---------~--~----~------------~-------~--~----~
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