On Tue, Oct 7, 2008 at 1:35 AM, Evan DeMond <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm writing a wxLua app which needs socket functionality, and I'm having
> trouble figuring out how to handle events from wxSocketClient. wxSocketBase
> doesn't inherit from wxEvtHandler, meaning Connect() isn't an option. I went
> looking and found this:
>
> http://docs.wxwidgets.org/stable/wx_wxsocketbase.html#socketevents
> http://docs.wxwidgets.org/stable/wx_wxsocketbase.html#wxsocketbaseseteventhandler
>
> So I tried to set up a plain wxEvtHandler object, hooking it up to the
> wxSocketClient with SetEventHandler(), and trying to Connect() the
> wxEvtHandler to wxSOCKET_INPUT - but that apparently fails?

wxSOCKET_INPUT is an enum wxSocketNotify, an integer with a value of
0, not an event type.

> "Lua: Error while running chunk
> ...
> wxLua: Invalid or unknown wxEventType for wxEvtHandler::Connect() : 0,
> winIds -1, -1."
>
> I can't seem to find any example code using wxSocketClient in Lua anywhere.
> All the C++ code I've seen uses the EVT_SOCKET macro, but that's not
> available in pure Lua.

The EVT_XXX() are C_++ macros that statically connect events at
compile time, so wxLua cannot use them, instead we use the dynamic
events and the wxEvtHandler::Connect() function.

The mapping between the EVT_XXX() macros and the dynamic event types
are described in the doc below. Search for EVT_SOCKET and you'll see
that you want to use wxEVT_SOCKET and that you will get a
wxSocketEvent object in your callback function. Note that the names
aren't always so easy to guess.

http://wxlua.sourceforge.net/docs/wxluaref.html

You can use any wxEvtHandler derived class you want, typically people
will use their wxFrame or a wxWindow that they already have.

Hope this helps,
     John

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to