# Paste event

**URL:** <https://www.ruby-forum.com/t/paste-event/174320>\
**Category:** wxRuby\
**Created:** [August 25, 2009, 1:17am UTC](https://www.ruby-forum.com/t/paste-event/174320 "2009-08-25T01:17:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pnomolos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/85f322/32.png) [@pnomolos](https://www.ruby-forum.com/u/pnomolos)\
**Post date:** [August 25, 2009, 1:17am UTC](https://www.ruby-forum.com/t/paste-event/174320/1 "2009-08-25T01:17:36Z")

</div>

Here’s my code for:

evt\_menu(@m\_menu\_paste) { pastetext } using wxruby2.0

def pastetext  
# this function is used to paste text from the clipboard and  
# does a simple test to see if the pasted text is a number  
# or a valid arithmetic expression  
# if not then restore the previous contents of the textctrl  
# (the calculator’s window) to its original state

```
  @m_textctrl.set_editable(true)
  start_value = @m_textctrl.get_value()
  @m_textctrl.paste

  end_value = @m_textctrl.get_value()

  puts "start value:::" + start_value
  puts "end value:::::" + end_value

  @m_textctrl.set_editable(false)

```

end

When I run my calculator program I get the following output

ClipBoard Data: 123456

Calculator’s textctrl: 0123456 # I’m not worried about the zero

Shell Output:

start value:::0  
end value:::::0 # I was hoping this would be 0123456

I was hoping that I could manipulate the end\_value but the paste event  
does not fire until after the routine is finished. I tried  
process\_event  
but could not manage to get the right syntax. Any help would be  
appreciated.

Thanks,  
Philip

---

<div class="post-metadata">

**Author:** ![pnomolos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/85f322/32.png) [@pnomolos](https://www.ruby-forum.com/u/pnomolos)\
**Post date:** [August 25, 2009, 9:19am UTC](https://www.ruby-forum.com/t/paste-event/174320/2 "2009-08-25T09:19:27Z")

</div>

Never mind, I found Wx::Clipboard which alowed me to do what I wanted to  
do which was validate text on a clip board before placing it in the  
calculator’s textctrl.

-Philip
