# Custom event problem

**URL:** <https://www.ruby-forum.com/t/custom-event-problem/191101>\
**Category:** wxRuby\
**Created:** [July 5, 2010, 4:58pm UTC](https://www.ruby-forum.com/t/custom-event-problem/191101 "2010-07-05T16:58:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [July 5, 2010, 4:58pm UTC](https://www.ruby-forum.com/t/custom-event-problem/191101/1 "2010-07-05T16:58:18Z")

</div>

I have some problem making a custom event.

It seem like the initilizer is not visible  
in the scope. Why is that?

I have put a little test program in an attachment,  
can anybody tell me, what is wrong with it?

---

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [July 7, 2010, 10:43am UTC](https://www.ruby-forum.com/t/custom-event-problem/191101/2 "2010-07-07T10:43:21Z")

</div>

On 05/07/2010 15:57, Svend Haugaard SÃ¸rensen wrote:

> I have some problem making a custom event.
> 
> It seem like the initilizer is not visible  
> in the scope. Why is that?

For some reason the allocator (constructor) function for Wx::Event is  
undefined - I’ve just checked the sources and I don’t know why SWIG is  
doing that. It may be a regression.

Can you inherit from Wx::CommandEvent or some other Event class instead.  
You are calling super with the parameters for Wx::CE anyway. That works  
fine for me (as per the sample).

PS - at line 21 you call Wx::EvtHandler.process\_event. #process\_event is  
an instance method, not a class method. Every Window, plus the App, has  
an event\_handler (with an accessor). You pass the event to one of those,  
normally the one where the event originates so that it can bubble  
upwards.

hth  
alex
