Extending Events
Lee McColl-Sylvester
lee.mccoll at lyons-group.co.uk
Fri Aug 4 05:48:02 PDT 2006
Hi Hans,
=
Thanks for that. I have the wxWidgets book, but it in no way hints to the =
fact you can include user data in the connect function. Had I known that, =
I would have solved this ages ago. Guess I should learn to look in the man=
ual from time to time. ;-)
=
Thank you. You've saved me hours of hair pulling.
=
Regards,
Lee
=
=
=
=
________________________________
From: Hans Harmon [mailto:hans_harmon at yahoo.com] =
Sent: 04 August 2006 13:30
To: wx-users at lists.wxwidgets.org
Subject: RE: Extending Events
=
Lee,
This is not complete, but should provide enough of a start to get things wo=
rking.
/////////////////////////////
// Begin code
struct ScriptData
{
scriptValue ctrl;
scriptValue evt;
scriptValue func;
};
class MyEvtHandler : EvtHandler()
{
// Have script use something like this.
void MyClass ::EventBind( scriptValue ctrl, scriptValue evt, scriptValu=
e func )
{
// Create some data to store, remember to delete this later.
ScriptData * newScriptData =3D new ScriptData();
newScriptData.ctrl =3D ctrl;
newScriptData.evt =3D evt;
newScriptData.fun =3D func;
// Select the type of event. To be used by the type of event
//...
// Get the event type and id information
wxEventType event_type =3D evt.event_type;
int event_id =3D evt.id;
=
// The this->OnEvent will need to be cast to the right type of even=
t handler, see wx/event.h for a list of these macros.
this->Connect ( event_id, event_type, wxMenuEventHandler ( this->On=
Event ), newScriptData, this );
}
OnEvent ( wxEvent &event )
{
ScriptData * scriptEventData;
scriptEventData =3D event.GetEventObject();
// Process the event using the ctrl, evt, and func values stored.
}
};
// End Code
/////////////////////
Also note that wxEventType is just an int. And look in event.h for a list =
of macros for the event function conversion. I just used wxMenuEventHandle=
r since your previous example showed a table that grabs all of the menu eve=
nts.
Hans
Lee McColl-Sylvester <lee.mccoll at lyons-group.co.uk> wrote:
Hi Hans,
=
Can you at least give a tiny example how I would pass data to an event type=
before calling the EvtHandler::Connect function?
=
Thanks,
Lee
=
=
=
________________________________
From: Hans Harmon [mailto:hans_harmon at yahoo.com] =
Sent: 04 August 2006 12:47
To: wx-users at lists.wxwidgets.org
Subject: Re: Extending Events
=
I would recommend looking at EvtHandler::Connect as this has solved some of=
my needs for dynamic events, without needing the macro table. You should =
be able to use the UserData pointer to pass whatever else you need for the =
event callback to work properly. Unfortunately I do not have any examples =
(that I can post), especially doing this with a scripting language.
Hans
Lee McColl-Sylvester <lee.mccoll at lyons-group.co.uk> wrote:
Hi List,
I'm intending on using wxWidgets to provide GUI support for a scripting
language, but I'm having trouble working out how best to support events.
I know that wxPython extends the event objects, but how do they then get
the widgets to send the events with the extended data?
For example, normally one would register an event and supply a function
pointer using the event table macros, but this won't be possible in my
cercumstance. I'm gonna need to register the event dynamically, passing
not only a function call but also various parameters that the function
will need to be able to proxy the event back to the scripting language.
Does anyone on this list have experience with this? Do you know of any
examples I can look at?
Regards,
Lee
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
=
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around =
http://mail.yahoo.com =
=
=
________________________________
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates =
starting at 1=A2/min. <http://us.rd.yahoo.com/mail_us/taglines/postman7/*ht=
tp:/us.rd.yahoo.com/evt=3D39666/*http:/messenger.yahoo.com> =
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20060804/3fc=
1654f/attachment.htm
More information about the wx-users
mailing list