From: John L. <jla...@gm...> - 2005-06-29 21:13:12
|
On 6/29/05, The Doctor <the...@bl...> wrote: > I tried PushEventHandler yesterday, and it caused a crash before the prog= ram showed anything on screen. I also tried SetEventHandler to make a Stati= cText handle all messages, and also making one button handle all of the mes= sages from the others, and each test failed. The one thing that has worked = is using SetEventHandler to the frame or the panel on it, I've not tried ot= her things. I'm sorry that all that is untested, at least by me. I guess I still don't understand why you don't want to just what's below, which is known to work and would seem to me to be simplier. Swapping out event handlers is not to be taken lightly, you really have to check out what going on when you do things like that. See here for what happens when you push/pop a handler. http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/src/common/wincmn.cpp?rev=3D= HEAD&content-type=3Dtext/vnd.viewcvs-markup search for: void wxWindowBase::PushEventHandler(wxEvtHandler *handler) Try doing this instead. function HandleButtonLeftUpEvent(event)=20 if event.GetId() =3D 1 then do stuff... else if event.GetId() =3D 2 then=20 ... end function MakeMyButton(parent, id, ...)\ local button =3D wx.wxButton(parent, id, ...) button:ConnectEvent(-1, wx.wxEVT_LEFT_UP, HandleButtonLeftUpEvent) button:ConnectEvent(-1, wx.wxEVT_RIGHT_UP, HandleButtonRightUpEvent) etc... return button end All you have to do to create a button is then MakeMyButton(PANEL, 10, ...) MakeMyButton(PANEL, 11, ...) |