Handling Events - Help

Hi all,

I have crated a application with two TextCtrl boxes (One for write and
the other to show the text that it’s written on the first box).

I try to use the “evt_text() { | event | }” but when I run the
application I have two problems:

When I press any key the application closes and I get this error:

C:/Program
Files/Ruby19/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-mingw32/lib/wx/accessors.rb:50:in
method_missing': undefined local variable or methodtext_box_2’ for
#MyFrame:0x1242cc0 (NameError)
from C:/Documentos/Ruby
Scripts/Text_Boxes/lib/Text_Boxes.rb:38:in block in initialize' from C:/Documentos/Ruby Scripts/Text_Boxes/lib/Text_Boxes.rb:50:incall’
from C:/Documentos/Ruby
Scripts/Text_Boxes/lib/Text_Boxes.rb:50:in process_event' from C:/Documentos/Ruby Scripts/Text_Boxes/lib/Text_Boxes.rb:50:inprocess_event’
from C:/Documentos/Ruby
Scripts/Text_Boxes/lib/Text_Boxes.rb:50:in process_event' from C:/Documentos/Ruby Scripts/Text_Boxes/lib/Text_Boxes.rb:50:inon_run’
from C:/Documentos/Ruby
Scripts/Text_Boxes/lib/Text_Boxes.rb:50:in main_loop' from C:/Documentos/Ruby Scripts/Text_Boxes/lib/Text_Boxes.rb:50:in

The second problem:

Since I’m a newbie I would like to know where can I find some help to
understand events syntax…

Thanks in advance

Ivo R.

Could you post a sytax for this and i will see if i can help.

Could you post a sytax for this and I will see if I can help.

Mark K.,

Now it’s almost working. I have been able to copy the content of
text_box_1 to text_box_2 with the following code.

require ‘wx’
include Wx

class MyFrame < Wx::Frame
def initialize
super(nil,
:id => -1,
:pos => DEFAULT_POSITION,
:title => ‘EasyMacro’,
:size => [900,600],
:style => DEFAULT_FRAME_STYLE,
:name => “Ivo”
)

@panel = Wx::Panel.new(self)

@text_box_1 = Wx::TextCtrl.new(@panel,
         :id => 1,
         :value => "Write your text here",
         :pos => [0,50],
         :size => [400,500],
         :style => TE_PROCESS_ENTER ,
         :validator => DEFAULT_VALIDATOR,
         :name => 'TextCtrlNameStr_1'

)

@text_box_2 = Wx::TextCtrl.new(@panel,
         :id => 2,
         :value => "",
         :pos => [450,50],
         :size => [400,500],
         :style => TE_READONLY,
         :validator => DEFAULT_VALIDATOR,
         :name => 'TextCtrlNameStr_2'

)

evt_text(@text_box_1.get_id()) {|event| show_text(event)}

show

end

def show_text(event)
text = @text_box_1.get_value()
@text_box_2.value = text
end

end

class MinApp < App
def on_init
frame = MyFrame.new
end
end

MinApp.new.main_loop

The only thing that I haven’t been able to do is to change line in
text_box_1 when I click Enter… Or any other key…

If you can help me with that I would be very appreciated.

Thanks in advance

Ivo R.