Ensure that validators work even in presence of pushed event handlers.
Call pre-processing hooks for each of the handlers in the chain and not only the first one. This ensures that a validator (which is invoked during the pre-processing stage) of a window is used even if a window has an event handler pushed on top of it. Closes #12177. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65006 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3253,11 +3253,19 @@ protected:
|
|||||||
// validators.
|
// validators.
|
||||||
virtual bool TryBefore(wxEvent& event);
|
virtual bool TryBefore(wxEvent& event);
|
||||||
|
|
||||||
// this one is not a hook but just a helper which looks up the handler in
|
// This one is not a hook but just a helper which looks up the handler in
|
||||||
// this object itself called from ProcessEventLocally() and normally
|
// this object itself.
|
||||||
// shouldn't be called directly as doing it would ignore any chained event
|
//
|
||||||
// handlers
|
// It is called from ProcessEventLocally() and normally shouldn't be called
|
||||||
bool TryHere(wxEvent& event);
|
// directly as doing it would ignore any chained event handlers
|
||||||
|
bool TryHereOnly(wxEvent& event);
|
||||||
|
|
||||||
|
// Another helper which simply calls pre-processing hook and then tries to
|
||||||
|
// handle the event at this handler level.
|
||||||
|
bool TryBeforeAndHere(wxEvent& event)
|
||||||
|
{
|
||||||
|
return TryBefore(event) || TryHereOnly(event);
|
||||||
|
}
|
||||||
|
|
||||||
// this one is called after failing to find the event handle in our own
|
// this one is called after failing to find the event handle in our own
|
||||||
// table to give a chance to the other windows to process it
|
// table to give a chance to the other windows to process it
|
||||||
|
@@ -1379,7 +1379,7 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
|
|||||||
// Short circuit the event processing logic if we're requested to process
|
// Short circuit the event processing logic if we're requested to process
|
||||||
// this event in this handler only, see DoTryChain() for more details.
|
// this event in this handler only, see DoTryChain() for more details.
|
||||||
if ( event.ShouldProcessOnlyIn(this) )
|
if ( event.ShouldProcessOnlyIn(this) )
|
||||||
return TryHere(event);
|
return TryBeforeAndHere(event);
|
||||||
|
|
||||||
|
|
||||||
// Try to process the event in this handler itself.
|
// Try to process the event in this handler itself.
|
||||||
@@ -1406,23 +1406,11 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
|
|||||||
|
|
||||||
bool wxEvtHandler::ProcessEventLocally(wxEvent& event)
|
bool wxEvtHandler::ProcessEventLocally(wxEvent& event)
|
||||||
{
|
{
|
||||||
// First try the hooks which should be called before our own handlers
|
// Try the hooks which should be called before our own handlers and this
|
||||||
if ( TryBefore(event) )
|
// handler itself first. Notice that we should not call ProcessEvent() on
|
||||||
return true;
|
// this one as we're already called from it, which explains why we do it
|
||||||
|
// here and not in DoTryChain()
|
||||||
// Then try this handler itself, notice that we should not call
|
return TryBeforeAndHere(event) || DoTryChain(event);
|
||||||
// ProcessEvent() on this one as we're already called from it, which
|
|
||||||
// explains why we do it here and not in DoTryChain()
|
|
||||||
if ( TryHere(event) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Finally try the event handlers chained to this one,
|
|
||||||
if ( DoTryChain(event) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// And return false to indicate that we didn't find any handler at this
|
|
||||||
// level.
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxEvtHandler::DoTryChain(wxEvent& event)
|
bool wxEvtHandler::DoTryChain(wxEvent& event)
|
||||||
@@ -1434,7 +1422,7 @@ bool wxEvtHandler::DoTryChain(wxEvent& event)
|
|||||||
// ProcessEvent() from which we were called or will be done by it when
|
// ProcessEvent() from which we were called or will be done by it when
|
||||||
// we return.
|
// we return.
|
||||||
//
|
//
|
||||||
// However we must call ProcessEvent() and not TryHere() because the
|
// However we must call ProcessEvent() and not TryHereOnly() because the
|
||||||
// existing code (including some in wxWidgets itself) expects the
|
// existing code (including some in wxWidgets itself) expects the
|
||||||
// overridden ProcessEvent() in its custom event handlers pushed on a
|
// overridden ProcessEvent() in its custom event handlers pushed on a
|
||||||
// window to be called.
|
// window to be called.
|
||||||
@@ -1478,7 +1466,7 @@ bool wxEvtHandler::DoTryChain(wxEvent& event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxEvtHandler::TryHere(wxEvent& event)
|
bool wxEvtHandler::TryHereOnly(wxEvent& event)
|
||||||
{
|
{
|
||||||
// If the event handler is disabled it doesn't process any events
|
// If the event handler is disabled it doesn't process any events
|
||||||
if ( !GetEvtHandlerEnabled() )
|
if ( !GetEvtHandlerEnabled() )
|
||||||
|
Reference in New Issue
Block a user