Re: HScale on_button_press_event blocking

On Wed, 9 May 2007, Patrick Schweiger <pschweiger symmetricom com> wrote :
On Tue, 2007-05-08 at 20:43 -0400, Jeremy Harmon wrote:

bool seekBar::on_button_press_event(GdkEventButton *event)
        m_isSeeking = true;
     return false;

instead of returning false, try calling the super class' implementations
to get the behavior they implement:

Just in case this seems bizarre or contrary to the documentation, I think it's worth adding a few comments.

When the GTK / GTKmm documentation says you return false to let other handlers operate, it refers to the way GTK itself hooks up a "list" of on-event call-backs. This ties several (possibly user-defined) functions to one GTK event. Each function can return true to say "I have now completely dealt with this event", or false to let other callbacks have their say.

However, when you _override_ a GTKmm class's existing handler, you are effectively replacing that function both in C++ terms and, consequently, in the GTK callback list. Thus if you want the super-class's functionality, your replacement virtual method must call its parent's version. This is normal behaviour for C++ (and other OO languages).

I hope that adds clarity and not confusion!
Rob Pearce             

The contents of this | Windows NT crashed.
message are purely   | I am the Blue Screen of Death.
my opinion. Don't    | No one hears your screams.
believe a word.      |

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]