# How to pass data from one textbox to another one?

**URL:** <https://www.ruby-forum.com/t/how-to-pass-data-from-one-textbox-to-another-one/188864>\
**Category:** Ruby\
**Created:** [May 19, 2010, 3:32pm UTC](https://www.ruby-forum.com/t/how-to-pass-data-from-one-textbox-to-another-one/188864 "2010-05-19T15:32:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iroupa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c0e974/32.png) [@iroupa](https://www.ruby-forum.com/u/iroupa)\
**Post date:** [May 19, 2010, 3:32pm UTC](https://www.ruby-forum.com/t/how-to-pass-data-from-one-textbox-to-another-one/188864/1 "2010-05-19T15:32:25Z")

</div>

Hi all,

I’m trying to create an simple application with two text boxes. One for  
writing and the other to show what I’m typing in textbox number one.

How can I use events to do that?

My code is this one:

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 => "",
         :pos => [0,50],
         :size => [400,500],
         :style => TE_MULTILINE,
         :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(1) { |event| @text_box_2 }

```

show  
end  
end

class MinApp \< App  
def on\_init  
frame = MyFrame.new  
end  
end

MinApp.new.main\_loop

Thanks in advance

Ivo R.
