# Notebook Change Page Event Handling

**URL:** <https://www.ruby-forum.com/t/notebook-change-page-event-handling/219808>\
**Category:** wxRuby\
**Created:** [May 16, 2012, 10:18pm UTC](https://www.ruby-forum.com/t/notebook-change-page-event-handling/219808 "2012-05-16T22:18:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 16, 2012, 10:18pm UTC](https://www.ruby-forum.com/t/notebook-change-page-event-handling/219808/1 "2012-05-16T22:18:23Z")

</div>

I’m still a bit new to Ruby, but have been using WxRuby for a couple of  
months now. I’ve created a notebook with a few pages, and am having a  
tough time understanding how to implement an event handler that would  
get called whenever the page gets changed.

Would someone be kind enough to post a simple example?

---

<div class="post-metadata">

**Author:** ![norbertl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c77e96/32.png) [@norbertl](https://www.ruby-forum.com/u/norbertl)\
**Post date:** [May 17, 2012, 11:23am UTC](https://www.ruby-forum.com/t/notebook-change-page-event-handling/219808/2 "2012-05-17T11:23:10Z")

</div>

hi

On 16/05/12 21:18, Norbert Lange wrote:

> I’m still a bit new to Ruby, but have been using WxRuby for a couple of  
> months now. I’ve created a notebook with a few pages, and am having a  
> tough time understanding how to implement an event handler that would  
> get called whenever the page gets changed.

Welcome to wxRuby. There are two events : evt\_notebook\_changing and  
evt\_notebook\_changed. They receive a Wx::NotebookEvent, and the former  
can be veto-ed if you want to prevent the change.

There’s an example within the bigdemo sample:  
[http://wxruby.rubyforge.org/svn/trunk/wxruby/samples/bigdemo/wxNotebook.rbw](http://wxruby.rubyforge.org/svn/trunk/wxruby/samples/bigdemo/wxNotebook.rbw)

alex

---

<div class="post-metadata">

**Author:** ![norbertl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c77e96/32.png) [@norbertl](https://www.ruby-forum.com/u/norbertl)\
**Post date:** [May 17, 2012, 5:28pm UTC](https://www.ruby-forum.com/t/notebook-change-page-event-handling/219808/3 "2012-05-17T17:28:36Z")

</div>

Alex F. wrote in post #1061104:

> hi
> 
> On 16/05/12 21:18, Norbert Lange wrote:
> 
> > I’m still a bit new to Ruby, but have been using WxRuby for a couple of  
> > months now. I’ve created a notebook with a few pages, and am having a  
> > tough time understanding how to implement an event handler that would  
> > get called whenever the page gets changed.
> 
> Welcome to wxRuby. There are two events : evt\_notebook\_changing and  
> evt\_notebook\_changed. They receive a Wx::NotebookEvent, and the former  
> can be veto-ed if you want to prevent the change.
> 
> There’s an example within the bigdemo sample:  
> [http://wxruby.rubyforge.org/svn/trunk/wxruby/samples/bigdemo/wxNotebook.rbw](http://wxruby.rubyforge.org/svn/trunk/wxruby/samples/bigdemo/wxNotebook.rbw)
> 
> alex

Thanks Alex. That’s exactly what I was looking for.

Norbert
