Hi,
I'm looking for a generic way to ignore/skip specific events, so i've got to intercept them before normal processing.
event.Skip() into associated event handler method does not skip the event.
My platform is Windows.
Thanks by advance
Generic way to intercept an event before processing ? Topic is solved
Hi,
You can use wxApp::FilterEvent. See http://forums.wxwidgets.org/viewtopic.php?t=14858 for an example.
Regards,
David
You can use wxApp::FilterEvent. See http://forums.wxwidgets.org/viewtopic.php?t=14858 for an example.
No, it's a slightly misleading name. wxEvent::Skip doesn't ignore the event, it reactivates it; so it will continue to be processed by the event system. If you catch an event and don't Skip it, the event is considered to have been sufficiently processed, and so dies.event.Skip() into associated event handler method does not skip the event.
Regards,
David
Well, in fact, it does not work .
I can surely intercept any kind of event, but for the one i'm trying to manage (wxEVT_ICONIZE) the frame is iconized whatever the code i add.
Any other idea ?
I can surely intercept any kind of event, but for the one i'm trying to manage (wxEVT_ICONIZE) the frame is iconized whatever the code i add.
Code: Select all
int MyApp::FilterEvent(wxEvent& event)
{
int rtn = -1;
if ( event.GetEventType() == wxEVT_ICONIZE && ((wxIconizeEvent&)event).Iconized() ) {
rtn = false;
}
return rtn;
}
Here's a hackish idea that seems to work on Windows:
If you experience flickering on other platforms you could try wrapping a freeze/thaw around the iconizing.
I noticed that if you attempt to iconize from a maximized window with this code, it will restore the window to normal size (ie: it won't be maximized). To avoid this you could check IsMaximized() and maximize the window to undo the iconize instead of calling Iconize(false).
Code: Select all
int MyApp::FilterEvent(wxEvent& evt)
{
if( evt.GetEventType() == wxEVT_ICONIZE && ((wxIconizeEvent&)evt).Iconized() )
{
myframe->Iconize(false);
}
return -1;
}
I noticed that if you attempt to iconize from a maximized window with this code, it will restore the window to normal size (ie: it won't be maximized). To avoid this you could check IsMaximized() and maximize the window to undo the iconize instead of calling Iconize(false).
This makes sense to me.TrV wrote:It's ashame, in wxwidgets manual, it clearly says "This function is called before processing any event and allows the application to preempt the processing of some events".
But the frame is iconize before FilterEvent() catches it.
Remeber that the iconizing triggers the event, not the other way around. So blocking the event would not prevent the iconize from happening, since it already happened by the time the event was triggered.