lua-users home
lua-l archive

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


> The Lua callback functions that wxLua uses for wxEvent handling are
> refed in the LUA_REGISTRYINDEX. Using them should not depend on them
> existing in the Lua global table.
> See here, do you get any of these error messages or something else?

No I don't believe I'm getting any of the errors generated from
wxLuaEventCallback::OnEvent. I'm not exactly sure where things get
screwed up, I think it's not the callbacks themselves but other stuff
they reference. I get a whole bunch (as in *a lot*) of errors about
trying to call or index nil values, each one in a fresh new popup
messagebox. That's where I tend to hit ctrl-c a couple of times. But
the errors all seem to originate from within callbacks, i.e. from the
Lua code.

I figured it should be possible with environments, because if I'm not
mistaken, making a module() out of that editor would also setfenv() it
implicitly, and that is known to work (Hakki Dogusan did it for his
CairoPad). I haven't had the time yet to look further into it, though.
But now I'm confused by what follows.

> Note that wxLua also calls setfenv() using the LUA_GLOBALSINDEX so
> that you can use local vars in your event handler.
> void wxLuaEventCallback::OnEvent(wxEvent *event)

Maybe I misunderstand. But if a callback function is created in some
non-global environment X, and then wxLua sets the environment for that
function to LUA_GLOBALSINDEX every time it is called, wouldn't that
mean it *can't* possibly find any other stuff that resides in X? It
looks like wxLua forces callbacks to run in the global environment,
regardless of what environment they were created in. Why is that? Or
is there something about all this that I'm getting all wrong?