lua-users home
lua-l archive

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

On Wed, Nov 13, 2013 at 10:28 PM, Andrew Starks <> wrote:

> At this point in my Lua C API experience, I'm much more likely to ask
> questions than answer them. Forgive me if this was already tried:
> When you create the button, store it in a weak-value table that is indexed
> by a lightuserdata value that you keep in C (a pointer). When the event
> fires, use the pointer as the ID.
> Hopefully that was a little helpful. :)
> -Andrew

I re-read the thread and then looked up what I thought I had read in
PiL. I think that this use case is actually the exact same use case
illustrated in PiL, as an example for light userdata.

The one detail that I had missed is that, when your C object emits an
event, you'll get a handle/pointer. This pointer is your light
userdata and is the key that references your value, which is the
specific object/userdata associated with the button/event.