wxlua icon indicating copy to clipboard operation
wxlua copied to clipboard

How to get a pointer to C++ object from wxLua object?

Open sokolas opened this issue 10 months ago • 1 comments

Hi!

I would like to send events to the wxFrame created in Lua from another thread from C++. According to the wxWidgets docs, I need the thread-safe wxEvtHandler::QueueEvent method. However, in order to use it, I need a pointer to an instance of wxEvtHandler (in my case, a wxFrame or wxApp, doesn't really matter).

The docs say that wxLua userdata objects have a special metatable, and its __tostring method:

print(wx.wxPoint()){.lua} prints "userdata: 0x858df5c [wxPoint(0x84ab550, 251)]", where 0x858df5c is the Lua userdata address, 0x84ab550 is the address of the wxPoint object

Is it possible to extract that pointer from wxLua userdata objects to pass it to my C++ code?

sokolas avatar Apr 09 '25 21:04 sokolas