Re: Creating and handling a non_GUI event

Mario Steele
Mon, 15 Apr 2013 19:05:35 -0000

Hello Eric,

Sorry for the late reply, I was busy with Windows issues, and couldn''t
test
with Ruby 2.0, as wxRuby needs to be compiled with Ruby 2.0.

In any case, after testing, and throwing in a require ''thread''
and
Thread.abort_on_exception = true, I found that when you sub-class a
Wx::Event, and attempt create a new instance of the sub-class, you will end
up with an internal error, saying that no allocator has been defined for
Wx::Event, which in all cases, is true, cause in C++ wxWidgets, Wx::Event,
isn''t a True Instantiate class.  In C++, the WxEvent Class is
considered an
Abstract Base Class, or to put it into Ruby Terms, consider WxEvent a
Module.

It defines the base methods and instance variables / structure of the class
for any sub-class of WxEvent, without actually having an allocator
associated with the base class itself.  So in order to actually get a Class
that is usable in Ruby, you need to sub-class a pre-existing C++ Class,
such as Wx::CommandEvent (WxCommandEvent class), in order to have it work
in Ruby.

I hope that this helps with your future programming.

Mario


On Thu, Apr 11, 2013 at 8:52 AM, Eric Rubin <lists@ruby-forum.com> wrote:

> Okay, here is a minimal test program (attached).
>
> I want my NonGuiThread to be able to change the value of the TextCtrl.
> Is add_pending_event the right way to do this?
>
> (It seems that TextMsgEvent should be an Event, not a CommandEvent,
> since it''s not a GUI event, but with Event the code
doesn''t work at
> all.)
>
> Thanks,
> Eric Rubin
>
> Attachments:
> http://www.ruby-forum.com/attachment/8322/event_test.rb
>
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> wxruby-users mailing list
> wxruby-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>



--
Mario Steele
Fleet Captain
CO - Geo 99
CO - USS T''hy''la
XO - Diplomatic Corps - Second Life
http://www.iftcommand.com/chapters/thyla/
http://www.trekfederation.com


_______________________________________________
wxruby-users mailing list
wxruby-users@rubyforge.org