lmi
[Top][All Lists]
Advanced

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

Re[2]: [lmi] Overriding wx member functions


From: Vadim Zeitlin
Subject: Re[2]: [lmi] Overriding wx member functions
Date: Thu, 1 Dec 2005 16:51:43 +0100

On Thu, 01 Dec 2005 03:04:00 +0000 Greg Chicares <address@hidden> wrote:

GC> Here's a different but related question. I have this code for class
GC>   DocMDIChildFrameEx
GC> which is derived from class
GC>   wxDocMDIChildFrame
GC> 
GC>   void DocMDIChildFrameEx::OnActivate(wxActivateEvent& event)
GC>   {
GC>       wxDocMDIChildFrame::OnActivate(event);
GC>       SetMdiWindowMenu();
GC>   }
GC> 
GC> I think you're saying that I should make the following change:
GC> 
GC> -      wxDocMDIChildFrame::OnActivate(event);
GC> +      event.Skip();

 Yes, indeed.

GC> and I'm trying to understand why. It seems to work fine either with
GC> or without that change.

 The most obvious reason is that the class wxDocMDIChildFrame
implementation (on another platform maybe) might not have OnActivate()
method at all. It's just an implementation detail and it definitely doesn't
work for all events: wxWindow doesn't have OnXXX() for all the hundreds of
wxXXXEvents in existence.

 Another reason is that there could be other event handlers connected to
the window which wouldn't get the event if you shortcircuit the event
propagation logic and don't let it run normally.


 The only problem with using event.Skip() is the order: in this case it
doesn't matter whether the base class version is called before or after
whatever the derived class does so it's not a problem to replace an
explicit function call with Skip() but if you want to do default processing
before your own, you're out of luck. This is an important limitation but
unfortunately I still have no idea how to fix it properly.

 Regards,
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]