# Cancel an event

**URL:** <https://www.ruby-forum.com/t/cancel-an-event/180260>\
**Category:** FXRuby\
**Created:** [December 16, 2009, 4:06am UTC](https://www.ruby-forum.com/t/cancel-an-event/180260 "2009-12-16T04:06:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [December 16, 2009, 4:06am UTC](https://www.ruby-forum.com/t/cancel-an-event/180260/1 "2009-12-16T04:06:39Z")

</div>

Hi all,

I want to do something like this:

button.connect(SEL\_COMMAND) do

… some code…  
if some\_condition then “cancel this event”

end

What I want is, a way to get out of the event’s code, without  
terminating the program. How do I do this?

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [January 1, 2010, 7:20pm UTC](https://www.ruby-forum.com/t/cancel-an-event/180260/2 "2010-01-01T19:20:28Z")

</div>

tuti plain wrote:

> Hi all,
> 
> I want to do something like this:
> 
> button.connect(SEL\_COMMAND) do
> 
> … some code…  
> if some\_condition then “cancel this event”
> 
> end
> 
> What I want is, a way to get out of the event’s code, without  
> terminating the program. How do I do this?

Have you tried:

… some code …  
if some\_condition then return end

Happy New Year
