[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Overriding wx member functions
From: |
Greg Chicares |
Subject: |
Re: [lmi] Overriding wx member functions |
Date: |
Thu, 01 Dec 2005 03:04:00 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
On 2005-11-27 14:58 UTC, Vadim Zeitlin wrote:
> On Sat, 26 Nov 2005 23:40:47 +0000 Greg Chicares <address@hidden> wrote:
>
> GC> 2. I noticed that the OnChildFocus() handler in 'xml_notebook.cpp'
>
> This is however quite different: OnChildFocus() is not a virtual function
> but a (non virtual) event handler. Event handlers can never call the base
> class event handler. All they can do is to call event.Skip() to let wx do
> it automatically. And the rule here is clear: if you are sure that you
> did everything necessary to process a given event, then don't call it. If
> you are not, then do. For the command events (button clicks, menu commands
> and so on) and update UI events you almost never want to call event.Skip()
> as there should be exactly one handler for them. For most of the others you
> almost always should skip the event.
Here's a different but related question. I have this code for class
DocMDIChildFrameEx
which is derived from class
wxDocMDIChildFrame
void DocMDIChildFrameEx::OnActivate(wxActivateEvent& event)
{
wxDocMDIChildFrame::OnActivate(event);
SetMdiWindowMenu();
}
I think you're saying that I should make the following change:
- wxDocMDIChildFrame::OnActivate(event);
+ event.Skip();
and I'm trying to understand why. It seems to work fine either with
or without that change.
I've studied
http://www.wxwidgets.org/manuals/2.6.2/wx_eventhandlingoverview.html#eventprocessing
which says
| instead of explicitly calling the base class version as you would
| have done with C++ virtual functions (i.e. wxTextCtrl::OnChar()),
| you should instead call Skip.
and, in the above example, I can confirm that calling Skip() works
just as well as calling the base-class version directly. What I
don't understand is why calling Skip() is better. What am I missing?